summaryrefslogtreecommitdiffhomepage
path: root/networking/udhcp/dhcpc.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-05-03 23:39:35 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-05-03 23:39:35 +0000
commit6e6d331d97aa230625c9b50c73f5df9251b8df4b (patch)
treef5ad77208e9a8da163cb347b5e3ceea648a8b7e7 /networking/udhcp/dhcpc.c
parentf71d916b60079f2009a714e49cb3e83efedbfb77 (diff)
udhcpc: stop deleting our own pidfile if we daemonize.
udhcp[cd]: stop using atexit magic fir pidfile removal.
Diffstat (limited to 'networking/udhcp/dhcpc.c')
-rw-r--r--networking/udhcp/dhcpc.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c
index 362e70169..06806ec66 100644
--- a/networking/udhcp/dhcpc.c
+++ b/networking/udhcp/dhcpc.c
@@ -116,6 +116,9 @@ static void client_background(void)
#else
// chdir(/) is problematic. Imagine that e.g. pidfile name is RELATIVE! what will unlink do then, eh?
bb_daemonize(DAEMON_CHDIR_ROOT);
+ /* rewrite pidfile, as our pid is different now */
+ if (client_config.pidfile)
+ write_pidfile(client_config.pidfile);
logmode &= ~LOGMODE_STDIO;
#endif
client_config.foreground = 1; /* Do not fork again. */
@@ -327,7 +330,8 @@ int udhcpc_main(int argc, char **argv)
client_background();
} else if (client_config.abort_if_no_lease) {
bb_info_msg("No lease, failing");
- return 1;
+ retval = 1;
+ goto ret;
}
/* wait to try again */
packet_num = 0;
@@ -483,7 +487,7 @@ int udhcpc_main(int argc, char **argv)
if (client_config.quit_after_lease) {
if (client_config.release_on_quit)
perform_release();
- return 0;
+ goto ret0;
}
if (!client_config.foreground)
client_background();
@@ -516,7 +520,7 @@ int udhcpc_main(int argc, char **argv)
bb_info_msg("Received SIGTERM");
if (client_config.release_on_quit)
perform_release();
- return 0;
+ goto ret0;
}
} else if (retval == -1 && errno == EINTR) {
/* a signal was caught */
@@ -524,7 +528,11 @@ int udhcpc_main(int argc, char **argv)
/* An error occured */
bb_perror_msg("select");
}
-
- }
- return 0;
+ } /* for (;;) */
+ ret0:
+ retval = 0;
+ ret:
+ if (client_config.pidfile)
+ remove_pidfile(client_config.pidfile);
+ return retval;
}