summaryrefslogtreecommitdiff
path: root/package/alix-switch/src
diff options
context:
space:
mode:
authorWaldemar Brodkorb <wbx@openadk.org>2010-06-28 13:23:59 +0200
committerWaldemar Brodkorb <wbx@openadk.org>2010-06-28 13:23:59 +0200
commit35c8150f713288319398ef855bbee58a49c855dd (patch)
tree2f21ecef9a9ab2efe0f56c56875c202e91860343 /package/alix-switch/src
parent6274e55f29fa492a2a34c437354c8fcc22e8a3d4 (diff)
boot into rescue mode, when button is pressed once
Diffstat (limited to 'package/alix-switch/src')
-rw-r--r--package/alix-switch/src/alix-switchd.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/package/alix-switch/src/alix-switchd.c b/package/alix-switch/src/alix-switchd.c
index d98748fa1..78b52f19c 100644
--- a/package/alix-switch/src/alix-switchd.c
+++ b/package/alix-switch/src/alix-switchd.c
@@ -44,18 +44,15 @@ static sighandler_t handle_signal (int sig_nr, sighandler_t signalhandler) {
static void start_daemon (void) {
int i;
- pid_t pid;
-
- if (setsid() > 0)
- exit(EXIT_FAILURE);
+ pid_t pid, sid;
handle_signal(SIGHUP, SIG_IGN);
-
if ((pid = fork ()) != 0)
exit(EXIT_FAILURE);
-
- chdir("/");
umask(0);
+ if ((sid = setsid()) < 0)
+ exit(EXIT_FAILURE);
+ chdir("/");
for (i = sysconf(_SC_OPEN_MAX); i > 0; i--)
close(i);
}