diff options
| author | Denys Vlasenko <vda.linux@googlemail.com> | 2016-01-17 01:09:36 +0100 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2016-01-17 01:10:53 +0100 |
| commit | ccf7f0e4d3aed3bd9f46a239d9033cd773e67ab8 (patch) | |
| tree | 488a7303e4994bd289eb0f3f57ea14cb3ae31aae /miscutils | |
| parent | 6a70db85cfc2aba89fc23edf426a47630f497eb8 (diff) | |
| download | busybox-w32-ccf7f0e4d3aed3bd9f46a239d9033cd773e67ab8.tar.gz busybox-w32-ccf7f0e4d3aed3bd9f46a239d9033cd773e67ab8.tar.bz2 busybox-w32-ccf7f0e4d3aed3bd9f46a239d9033cd773e67ab8.zip | |
setsid: implement -c
function old new delta
setsid_main 53 96 +43
packed_usage 30846 30833 -13
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'miscutils')
| -rw-r--r-- | miscutils/setsid.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/miscutils/setsid.c b/miscutils/setsid.c index 637081b6c..1b27377b2 100644 --- a/miscutils/setsid.c +++ b/miscutils/setsid.c | |||
| @@ -15,19 +15,22 @@ | |||
| 15 | */ | 15 | */ |
| 16 | 16 | ||
| 17 | //usage:#define setsid_trivial_usage | 17 | //usage:#define setsid_trivial_usage |
| 18 | //usage: "PROG ARGS" | 18 | //usage: "[-c] PROG ARGS" |
| 19 | //usage:#define setsid_full_usage "\n\n" | 19 | //usage:#define setsid_full_usage "\n\n" |
| 20 | //usage: "Run PROG in a new session. PROG will have no controlling terminal\n" | 20 | //usage: "Run PROG in a new session. PROG will have no controlling terminal\n" |
| 21 | //usage: "and will not be affected by keyboard signals (Ctrl-C etc).\n" | 21 | //usage: "and will not be affected by keyboard signals (^C etc).\n" |
| 22 | //usage: "See setsid(2) for details." | 22 | //usage: "\n -c Set controlling terminal to stdin" |
| 23 | 23 | ||
| 24 | #include "libbb.h" | 24 | #include "libbb.h" |
| 25 | 25 | ||
| 26 | int setsid_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 26 | int setsid_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
| 27 | int setsid_main(int argc UNUSED_PARAM, char **argv) | 27 | int setsid_main(int argc UNUSED_PARAM, char **argv) |
| 28 | { | 28 | { |
| 29 | if (!argv[1]) | 29 | unsigned opt; |
| 30 | bb_show_usage(); | 30 | |
| 31 | opt_complementary = "-1"; /* at least one arg */ | ||
| 32 | opt = getopt32(argv, "c"); | ||
| 33 | argv += optind; | ||
| 31 | 34 | ||
| 32 | /* setsid() is allowed only when we are not a process group leader. | 35 | /* setsid() is allowed only when we are not a process group leader. |
| 33 | * Otherwise our PID serves as PGID of some existing process group | 36 | * Otherwise our PID serves as PGID of some existing process group |
| @@ -61,6 +64,10 @@ int setsid_main(int argc UNUSED_PARAM, char **argv) | |||
| 61 | setsid(); | 64 | setsid(); |
| 62 | } | 65 | } |
| 63 | 66 | ||
| 64 | argv++; | 67 | if (opt) { |
| 68 | /* -c: set (with stealing) controlling tty */ | ||
| 69 | ioctl(0, TIOCSCTTY, 1); | ||
| 70 | } | ||
| 71 | |||
| 65 | BB_EXECVP_or_die(argv); | 72 | BB_EXECVP_or_die(argv); |
| 66 | } | 73 | } |
