1
0
mirror of git://git.suckless.org/ubase synced 2024-12-22 06:40:38 +00:00

Add single shot option for pidof(8)

This commit is contained in:
sin 2013-08-31 17:33:45 +01:00
parent 6a1970caa4
commit 1927d28990

View File

@ -10,7 +10,7 @@
static void
usage(void)
{
eprintf("usage: %s [program...]\n", argv0);
eprintf("usage: %s [-s] [program...]\n", argv0);
}
int
@ -22,8 +22,12 @@ main(int argc, char *argv[])
struct procstat ps;
char cmdline[BUFSIZ], *cmd, *p;
int i, found = 0;
int sflag = 0;
ARGBEGIN {
case 's':
sflag = 1;
break;
default:
usage();
} ARGEND;
@ -51,10 +55,13 @@ main(int argc, char *argv[])
if (strcmp(cmd, argv[i]) == 0) {
putword(entry->d_name);
found++;
if (sflag)
goto out;
}
}
}
out:
if (found)
putchar('\n');