Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 38e5f07c authored by Glenn Kasten's avatar Glenn Kasten Committed by Colin Cross
Browse files

toolbox: Add nohup command



Change-Id: I2f7d9934b54d98886d7a6205ea122d9ce91066ec
Signed-off-by: default avatarDmitry Shmidt <dimitrysh@google.com>
parent 304d31f0
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ TOOLS := \
	nandread \
	netstat \
	newfs_msdos \
	nohup \
	notify \
	printenv \
	ps \

toolbox/nohup.c

0 → 100644
+26 −0
Original line number Diff line number Diff line
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

int nohup_main(int argc, char *argv[])
{
    if (argc < 2) {
        fprintf(stderr, "Usage: %s [-n] program args...\n", argv[0]);
        return EXIT_FAILURE;
    }
    signal(SIGHUP, SIG_IGN);
    argv++;
    if (strcmp(argv[0], "-n") == 0) {
        argv++;
        signal(SIGINT, SIG_IGN);
        signal(SIGSTOP, SIG_IGN);
        signal(SIGTTIN, SIG_IGN);
        signal(SIGTTOU, SIG_IGN);
        signal(SIGQUIT, SIG_IGN);
        signal(SIGTERM, SIG_IGN);
    }
    execvp(argv[0], argv);
    perror(argv[0]);
    return EXIT_FAILURE;
}