From 882cc0a4456bd161c7c95fb6c956b50c7b42f343 Mon Sep 17 00:00:00 2001 From: kernaltrap8 Date: Tue, 18 Jun 2024 21:52:45 -0500 Subject: [PATCH] im stupid Signed-off-by: kernaltrap8 --- src/proctl.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/proctl.c b/src/proctl.c index baa7e7c..4190338 100644 --- a/src/proctl.c +++ b/src/proctl.c @@ -15,15 +15,15 @@ #include #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; @@ -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) {