Skip to content

Commit

Permalink
im stupid
Browse files Browse the repository at this point in the history
Signed-off-by: kernaltrap8 <[email protected]>
  • Loading branch information
kernaltrap8 committed Jun 19, 2024
1 parent 80fe14d commit 882cc0a
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/proctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
#include <unistd.h>

#define VERSION \
"proctl v1.3\nThis program is licensed under GNU GPLv3 and comes with " \
"proctl v1.5\nThis program is licensed under GNU GPLv3 and comes with " \
"ABSOLUTELY NO WARRANTY.\nThe license " \
"document can be viewed at https://www.gnu.org/licenses/gpl-3.0.en.html\n"
#define HELP \
"proctl\n -v, --version \n Version and license info.\n -h, " \
"proctl v1.5\n -v, --version \n Version and license info.\n -h, " \
"--help\n " \
" Show this help banner.\n -k, --kill\n Kill process without " \
"respawning it.\n-l, --launch\n Spawns a process even if it doesnt " \
"exist.\n"
"respawning it.\n -l, --launch\n Spawns a process even if it doesnt " \
"exist.\n -p, --pid\n Returns the PID of a given process.\n"

int get_pid_by_name(const char *proc_name) {
DIR *dir;
Expand Down Expand Up @@ -146,6 +146,11 @@ int main(int argc, char *argv[]) {
}
}

if (!strcmp(argv[1], "-p") || !strcmp(argv[1], "--pid")) {
printf("%i", get_pid_by_name(argv[2]));
return 0;
}

if (!strcmp(argv[1], "-l") || !strcmp(argv[1], "--launch")) {
int pid = get_pid_by_name(argv[2]);
if (pid == -1) {
Expand Down

0 comments on commit 882cc0a

Please sign in to comment.