summaryrefslogtreecommitdiff
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)
downloadbusybox-w32-6e6d331d97aa230625c9b50c73f5df9251b8df4b.tar.gz
busybox-w32-6e6d331d97aa230625c9b50c73f5df9251b8df4b.tar.bz2
busybox-w32-6e6d331d97aa230625c9b50c73f5df9251b8df4b.zip
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)
116#else 116#else
117// chdir(/) is problematic. Imagine that e.g. pidfile name is RELATIVE! what will unlink do then, eh? 117// chdir(/) is problematic. Imagine that e.g. pidfile name is RELATIVE! what will unlink do then, eh?
118 bb_daemonize(DAEMON_CHDIR_ROOT); 118 bb_daemonize(DAEMON_CHDIR_ROOT);
119 /* rewrite pidfile, as our pid is different now */
120 if (client_config.pidfile)
121 write_pidfile(client_config.pidfile);
119 logmode &= ~LOGMODE_STDIO; 122 logmode &= ~LOGMODE_STDIO;
120#endif 123#endif
121 client_config.foreground = 1; /* Do not fork again. */ 124 client_config.foreground = 1; /* Do not fork again. */
@@ -327,7 +330,8 @@ int udhcpc_main(int argc, char **argv)
327 client_background(); 330 client_background();
328 } else if (client_config.abort_if_no_lease) { 331 } else if (client_config.abort_if_no_lease) {
329 bb_info_msg("No lease, failing"); 332 bb_info_msg("No lease, failing");
330 return 1; 333 retval = 1;
334 goto ret;
331 } 335 }
332 /* wait to try again */ 336 /* wait to try again */
333 packet_num = 0; 337 packet_num = 0;
@@ -483,7 +487,7 @@ int udhcpc_main(int argc, char **argv)
483 if (client_config.quit_after_lease) { 487 if (client_config.quit_after_lease) {
484 if (client_config.release_on_quit) 488 if (client_config.release_on_quit)
485 perform_release(); 489 perform_release();
486 return 0; 490 goto ret0;
487 } 491 }
488 if (!client_config.foreground) 492 if (!client_config.foreground)
489 client_background(); 493 client_background();
@@ -516,7 +520,7 @@ int udhcpc_main(int argc, char **argv)
516 bb_info_msg("Received SIGTERM"); 520 bb_info_msg("Received SIGTERM");
517 if (client_config.release_on_quit) 521 if (client_config.release_on_quit)
518 perform_release(); 522 perform_release();
519 return 0; 523 goto ret0;
520 } 524 }
521 } else if (retval == -1 && errno == EINTR) { 525 } else if (retval == -1 && errno == EINTR) {
522 /* a signal was caught */ 526 /* a signal was caught */
@@ -524,7 +528,11 @@ int udhcpc_main(int argc, char **argv)
524 /* An error occured */ 528 /* An error occured */
525 bb_perror_msg("select"); 529 bb_perror_msg("select");
526 } 530 }
527 531 } /* for (;;) */
528 } 532 ret0:
529 return 0; 533 retval = 0;
534 ret:
535 if (client_config.pidfile)
536 remove_pidfile(client_config.pidfile);
537 return retval;
530} 538}