Skip to content

Commit

Permalink
strip some code and add some helpful logging
Browse files Browse the repository at this point in the history
  • Loading branch information
henrik242 committed Jan 11, 2024
1 parent c26014c commit a56a63c
Show file tree
Hide file tree
Showing 4 changed files with 297 additions and 382 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
OS := $(shell uname)
COMPILER := $(shell test "${OS}" = "Linux" -a -x "/bin/g++" && echo "_gcc")

BUILD_Darwin = clang++ procenv.cpp process.cpp -o procenv -std=c++17 -Wall -arch arm64 -arch x86_64
BUILD_Darwin = clang++ procenv.cpp process.cpp -o procenv -g -std=c++17 -Wall -arch arm64 -arch x86_64
BUILD_Linux_gcc = g++ procenv.cpp process.cpp -o procenv -std=c++17 -Wall -static-libgcc -static-libstdc++ -static
BUILD_Linux = clang++ procenv.cpp process.cpp -o procenv -std=c++17 -Wall
BUILD_FreeBSD = clang++ procenv.cpp process.cpp -o procenv -std=c++17 -Wall -lelf -lkvm -lpthread -static
Expand All @@ -13,7 +13,7 @@ BUILD_Windows = g++ procenv.cpp process.cpp -o procenv.exe -std=c++17 -Wall -sta

BUILD = ${BUILD_${OS}${COMPILER}}

procenv: procenv.cpp process.cpp process.hpp
procenv: procenv.cpp process.cpp process.hpp Makefile
ifeq (${BUILD},)
@echo "Unsupported OS/compiler combination: ${OS}${COMPILER}"
@exit 1
Expand Down
15 changes: 5 additions & 10 deletions procenv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,10 @@ int main(int argc, char **argv) {
printf("procenv <pid>\n");
return 0;
}
int thepid = std::stoi(argv[1]);
std::vector<ngs::ps::NGS_PROCID> pids = ngs::ps::proc_id_enum();

for (std::size_t i = 0; i < pids.size(); i++) {
std::vector<std::string> env = ngs::ps::environ_from_proc_id(pids[i]);
for (std::size_t j = 0; j < env.size(); j++)
if (pids[i] == thepid) {
std::cout << env[j] << "\n";
}
}
int proc_id = std::stoi(argv[1]);
std::vector<std::string> env = ngs::ps::environ_from_proc_id(proc_id);
for (std::size_t j = 0; j < env.size(); j++) {
std::cout << env[j] << "\n";
}
return 0;
}
Loading

0 comments on commit a56a63c

Please sign in to comment.