aboutsummaryrefslogtreecommitdiff
path: root/toys/posix/nohup.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2012-11-13 17:14:08 -0600
committerRob Landley <rob@landley.net>2012-11-13 17:14:08 -0600
commit7aa651a6a4496d848f86de9b1e6b3a003256a01f (patch)
tree6995fb4b7cc2e90a6706b0239ebaf95d9dbab530 /toys/posix/nohup.c
parent571b0706cce45716126776d0ad0f6ac65f4586e3 (diff)
downloadtoybox-7aa651a6a4496d848f86de9b1e6b3a003256a01f.tar.gz
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.
Diffstat (limited to 'toys/posix/nohup.c')
-rw-r--r--toys/posix/nohup.c50
1 files changed, 24 insertions, 26 deletions
diff --git a/toys/posix/nohup.c b/toys/posix/nohup.c
index e11fb094..b936a093 100644
--- a/toys/posix/nohup.c
+++ b/toys/posix/nohup.c
@@ -1,6 +1,4 @@
-/* vi: set sw=4 ts=4:
- *
- * nohup.c - run commandline with SIGHUP blocked.
+/* nohup.c - run commandline with SIGHUP blocked.
*
* Copyright 2011 Rob Landley <rob@landley.net>
*
@@ -9,34 +7,34 @@
USE_NOHUP(NEWTOY(nohup, "<1", TOYFLAG_USR|TOYFLAG_BIN))
config NOHUP
- bool "nohup"
- default y
- help
- usage: nohup COMMAND [ARGS...]
+ bool "nohup"
+ default y
+ help
+ usage: nohup COMMAND [ARGS...]
- Run a command that survives the end of its terminal.
- If stdin is a tty, redirect from /dev/null
- If stdout is a tty, redirect to file "nohup.out"
+ Run a command that survives the end of its terminal.
+ If stdin is a tty, redirect from /dev/null
+ If stdout is a tty, redirect to file "nohup.out"
*/
#include "toys.h"
void nohup_main(void)
{
- signal(SIGHUP, SIG_IGN);
- if (isatty(1)) {
- close(1);
- if (-1 == open("nohup.out", O_CREAT|O_APPEND|O_WRONLY,
- S_IRUSR|S_IWUSR ))
- {
- char *temp = getenv("HOME");
- temp = xmsprintf("%s/%s", temp ? temp : "", "nohup.out");
- xcreate(temp, O_CREAT|O_APPEND|O_WRONLY, S_IRUSR|S_IWUSR);
- }
- }
- if (isatty(0)) {
- close(0);
- open("/dev/null", O_RDONLY);
- }
- xexec(toys.optargs);
+ signal(SIGHUP, SIG_IGN);
+ if (isatty(1)) {
+ close(1);
+ if (-1 == open("nohup.out", O_CREAT|O_APPEND|O_WRONLY,
+ S_IRUSR|S_IWUSR ))
+ {
+ char *temp = getenv("HOME");
+ temp = xmsprintf("%s/%s", temp ? temp : "", "nohup.out");
+ xcreate(temp, O_CREAT|O_APPEND|O_WRONLY, S_IRUSR|S_IWUSR);
+ }
+ }
+ if (isatty(0)) {
+ close(0);
+ open("/dev/null", O_RDONLY);
+ }
+ xexec(toys.optargs);
}