aboutsummaryrefslogtreecommitdiff
path: root/miscutils
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2001-07-19 22:28:02 +0000
committerEric Andersen <andersen@codepoet.org>2001-07-19 22:28:02 +0000
commit20aab260e2f7011523402464fb079f48e5899890 (patch)
treef7822e652f54884459d525f57f1ef18c03a126f7 /miscutils
parent0382eb886529fc4dab170e7d66883c20fe0e2883 (diff)
downloadbusybox-20aab260e2f7011523402464fb079f48e5899890.tar.gz
Some adjustments, mostly from David McCullough <davidm@lineo.com> to
make busybox be more uClinux friendly. I also adjusted Config.h for uClinux so it will automagically disable apps the arn't going to work without fork() and such. -Erik
Diffstat (limited to 'miscutils')
-rw-r--r--miscutils/update.c60
1 files changed, 29 insertions, 31 deletions
diff --git a/miscutils/update.c b/miscutils/update.c
index a6550b05c..603740e38 100644
--- a/miscutils/update.c
+++ b/miscutils/update.c
@@ -65,46 +65,44 @@ extern int update_main(int argc, char **argv)
show_usage();
}
}
+
+ if (daemon(0, 1) < 0)
+ perror_msg_and_die("daemon");
- pid = fork();
- if (pid < 0)
- return EXIT_FAILURE;
- else if (pid == 0) {
- /* Become a proper daemon */
- setsid();
- chdir("/");
+ /* Become a proper daemon */
+ setsid();
+ chdir("/");
#ifdef OPEN_MAX
- for (pid = 0; pid < OPEN_MAX; pid++) close(pid);
+ for (pid = 0; pid < OPEN_MAX; pid++) close(pid);
#else
- /* glibc 2.1.92 requires using sysconf(_SC_OPEN_MAX) */
- for (pid = 0; pid < sysconf(_SC_OPEN_MAX); pid++) close(pid);
+ /* glibc 2.1.92 requires using sysconf(_SC_OPEN_MAX) */
+ for (pid = 0; pid < sysconf(_SC_OPEN_MAX); pid++) close(pid);
#endif
- /*
- * This is no longer necessary since 1.3.5x, but it will harmlessly
- * exit if that is the case.
- */
+ /* This is no longer necessary since 1.3.5x, but it will harmlessly
+ * exit if that is the case.
+ */
- /* set the program name that will show up in a 'ps' listing */
- argv[0] = "bdflush (update)";
- argv[1] = NULL;
- argv[2] = NULL;
- for (;;) {
- if (use_sync) {
- sleep(sync_duration);
- sync();
- } else {
- sleep(flush_duration);
- if (bdflush(1, 0) < 0) {
- openlog("update", LOG_CONS, LOG_DAEMON);
- syslog(LOG_INFO,
- "This kernel does not need update(8). Exiting.");
- closelog();
- return EXIT_SUCCESS;
- }
+ /* set the program name that will show up in a 'ps' listing */
+ argv[0] = "bdflush (update)";
+ argv[1] = NULL;
+ argv[2] = NULL;
+ for (;;) {
+ if (use_sync) {
+ sleep(sync_duration);
+ sync();
+ } else {
+ sleep(flush_duration);
+ if (bdflush(1, 0) < 0) {
+ openlog("update", LOG_CONS, LOG_DAEMON);
+ syslog(LOG_INFO,
+ "This kernel does not need update(8). Exiting.");
+ closelog();
+ return EXIT_SUCCESS;
}
}
}
+
return EXIT_SUCCESS;
}