toolbox: Add nohup command
Change-Id: I2f7d9934b54d98886d7a6205ea122d9ce91066ec Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
This commit is contained in:
parent
4676550b56
commit
3707e7ff03
2 changed files with 28 additions and 1 deletions
|
@ -69,7 +69,8 @@ TOOLS := \
|
|||
swapon \
|
||||
swapoff \
|
||||
mkswap \
|
||||
readlink
|
||||
readlink \
|
||||
nohup
|
||||
|
||||
ifneq (,$(filter userdebug eng,$(TARGET_BUILD_VARIANT)))
|
||||
TOOLS += r
|
||||
|
|
26
toolbox/nohup.c
Normal file
26
toolbox/nohup.c
Normal file
|
@ -0,0 +1,26 @@
|
|||
#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;
|
||||
}
|
Loading…
Reference in a new issue