From 6e6d331d97aa230625c9b50c73f5df9251b8df4b Mon Sep 17 00:00:00 2001 From: Denis Vlasenko Date: Thu, 3 May 2007 23:39:35 +0000 Subject: udhcpc: stop deleting our own pidfile if we daemonize. udhcp[cd]: stop using atexit magic fir pidfile removal. --- networking/udhcp/dhcpc.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'networking/udhcp/dhcpc.c') 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; } -- cgit v1.2.3