summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Kasten <gkasten@google.com>2013-09-23 15:10:12 -0700
committerColin Cross <ccross@android.com>2014-06-11 11:10:28 -0700
commit38e5f07c0f93e333b35cffc9bb902de599a3bef9 (patch)
tree389ff9b4ed842b1f16ce615db5e9c2bfe9c7243c
parent304d31f05ee76a834209ad837ce78255cf70ae5f (diff)
downloadsystem_core-38e5f07c0f93e333b35cffc9bb902de599a3bef9.zip
system_core-38e5f07c0f93e333b35cffc9bb902de599a3bef9.tar.gz
system_core-38e5f07c0f93e333b35cffc9bb902de599a3bef9.tar.bz2
toolbox: Add nohup command
Change-Id: I2f7d9934b54d98886d7a6205ea122d9ce91066ec Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
-rw-r--r--toolbox/Android.mk1
-rw-r--r--toolbox/nohup.c26
2 files changed, 27 insertions, 0 deletions
diff --git a/toolbox/Android.mk b/toolbox/Android.mk
index 77df4d4..6bac5f5 100644
--- a/toolbox/Android.mk
+++ b/toolbox/Android.mk
@@ -39,6 +39,7 @@ TOOLS := \
nandread \
netstat \
newfs_msdos \
+ nohup \
notify \
printenv \
ps \
diff --git a/toolbox/nohup.c b/toolbox/nohup.c
new file mode 100644
index 0000000..363999d
--- /dev/null
+++ b/toolbox/nohup.c
@@ -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;
+}