Mercurial > hg > toybox
comparison toys/lsb/pidof.c @ 694:786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
The actual code should be the same afterward, this is just cosmetic refactoring.
author | Rob Landley <rob@landley.net> |
---|---|
date | Tue, 13 Nov 2012 17:14:08 -0600 |
parents | 6df4ccc0acbe |
children | 43e6ec52aa29 |
comparison
equal
deleted
inserted
replaced
693:4a5a250e0633 | 694:786841fdb1e0 |
---|---|
1 /* vi: set sw=4 ts=4: | 1 /* pidof.c - Print the Process IDs of all processes with the given names. |
2 * | |
3 * pidof.c - Print the PIDs of all processes with the given names. | |
4 * | 2 * |
5 * Copyright 2012 Andreas Heck <aheck@gmx.de> | 3 * Copyright 2012 Andreas Heck <aheck@gmx.de> |
6 * | 4 * |
7 * http://refspecs.linuxfoundation.org/LSB_4.1.0/LSB-Core-generic/LSB-Core-generic/pidof.html | 5 * http://refspecs.linuxfoundation.org/LSB_4.1.0/LSB-Core-generic/LSB-Core-generic/pidof.html |
8 | 6 |
9 USE_PIDOF(NEWTOY(pidof, "<1", TOYFLAG_USR|TOYFLAG_BIN)) | 7 USE_PIDOF(NEWTOY(pidof, "<1", TOYFLAG_USR|TOYFLAG_BIN)) |
10 | 8 |
11 config PIDOF | 9 config PIDOF |
12 bool "pidof" | 10 bool "pidof" |
13 default y | 11 default y |
14 help | 12 help |
15 usage: pidof [NAME]... | 13 usage: pidof [NAME]... |
16 | 14 |
17 Print the PIDs of all processes with the given names. | 15 Print the PIDs of all processes with the given names. |
18 */ | 16 */ |
19 | 17 |
20 #include "toys.h" | 18 #include "toys.h" |
21 | 19 |
22 static void print_pid(pid_t pid) { | 20 static void print_pid(pid_t pid) |
23 xprintf("%s%ld", toys.exitval ? "" : " ", (long)pid); | 21 { |
24 toys.exitval = 0; | 22 xprintf("%s%ld", toys.exitval ? "" : " ", (long)pid); |
23 toys.exitval = 0; | |
25 } | 24 } |
26 | 25 |
27 void pidof_main(void) | 26 void pidof_main(void) |
28 { | 27 { |
29 toys.exitval = 1; | 28 toys.exitval = 1; |
30 for_each_pid_with_name_in(toys.optargs, print_pid); | 29 for_each_pid_with_name_in(toys.optargs, print_pid); |
31 if (!toys.exitval) xputc('\n'); | 30 if (!toys.exitval) xputc('\n'); |
32 } | 31 } |