Mercurial > hg > toybox
comparison toys/nohup.c @ 422:82d70cff7357
Very slight efficiency tweak.
author | Rob Landley <rob@landley.net> |
---|---|
date | Thu, 02 Feb 2012 07:42:31 -0600 |
parents | 5e9c1d73c84a |
children |
comparison
equal
deleted
inserted
replaced
421:1ca548d46c8e | 422:82d70cff7357 |
---|---|
22 #include "toys.h" | 22 #include "toys.h" |
23 | 23 |
24 void nohup_main(void) | 24 void nohup_main(void) |
25 { | 25 { |
26 signal(SIGHUP, SIG_IGN); | 26 signal(SIGHUP, SIG_IGN); |
27 if (ttyname(1)) { | 27 if (isatty(1)) { |
28 close(1); | 28 close(1); |
29 if (-1 == open("nohup.out", O_CREAT|O_APPEND|O_WRONLY, | 29 if (-1 == open("nohup.out", O_CREAT|O_APPEND|O_WRONLY, |
30 S_IRUSR|S_IWUSR )) | 30 S_IRUSR|S_IWUSR )) |
31 { | 31 { |
32 char *temp = getenv("HOME"); | 32 char *temp = getenv("HOME"); |
33 temp = xmsprintf("%s/%s", temp ? temp : "", "nohup.out"); | 33 temp = xmsprintf("%s/%s", temp ? temp : "", "nohup.out"); |
34 xcreate(temp, O_CREAT|O_APPEND|O_WRONLY, S_IRUSR|S_IWUSR); | 34 xcreate(temp, O_CREAT|O_APPEND|O_WRONLY, S_IRUSR|S_IWUSR); |
35 } | 35 } |
36 } | 36 } |
37 if (ttyname(0)) { | 37 if (isatty(0)) { |
38 close(0); | 38 close(0); |
39 open("/dev/null", O_RDONLY); | 39 open("/dev/null", O_RDONLY); |
40 } | 40 } |
41 xexec(toys.optargs); | 41 xexec(toys.optargs); |
42 } | 42 } |