simpler nohup

This commit is contained in:
Connor Lane Smith 2011-06-24 08:33:08 +01:00
parent a051bab859
commit 572f5e926c
1 changed files with 2 additions and 4 deletions

View File

@ -13,16 +13,14 @@ int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
int fd; int fd;
struct sigaction sa;
if(getopt(argc, argv, "") != -1) if(getopt(argc, argv, "") != -1)
exit(Error); exit(Error);
if(optind == argc) if(optind == argc)
enprintf(Error, "usage: %s command [argument...]\n", argv[0]); enprintf(Error, "usage: %s command [argument...]\n", argv[0]);
sa.sa_handler = SIG_IGN; if(signal(SIGHUP, SIG_IGN) == SIG_ERR)
if(sigaction(SIGHUP, &sa, NULL) == -1) enprintf(Error, "signal HUP:");
enprintf(Error, "sigaction HUP:");
if(isatty(STDOUT_FILENO)) { if(isatty(STDOUT_FILENO)) {
if((fd = open("nohup.out", O_APPEND|O_CREAT, S_IRUSR|S_IWUSR)) == -1) if((fd = open("nohup.out", O_APPEND|O_CREAT, S_IRUSR|S_IWUSR)) == -1)
enprintf(Error, "open nohup.out:"); enprintf(Error, "open nohup.out:");