*: code shrink and better "died from signal" reporting from wait4pid
function old new delta parse 964 967 +3 udhcp_run_script 670 665 -5 singlemount 911 906 -5 mount_it_now 360 355 -5 inotifyd_main 521 516 -5 xspawn 21 - -21 ------------------------------------------------------------------------------ (add/remove: 0/1 grow/shrink: 1/4 up/down: 3/-41) Total: -38 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
@@ -132,10 +132,10 @@ static int run_script(const char *action)
|
||||
argv[3] = (char*) G.extra_arg;
|
||||
argv[4] = NULL;
|
||||
|
||||
/* r < 0 - can't exec, 0 <= r < 1000 - exited, >1000 - killed by sig (r-1000) */
|
||||
r = wait4pid(spawn(argv));
|
||||
/* r < 0 - can't exec, 0 <= r < 0x180 - exited, >=0x180 - killed by sig (r-0x180) */
|
||||
r = spawn_and_wait(argv);
|
||||
|
||||
bb_error_msg("exit code: %d", r);
|
||||
bb_error_msg("exit code: %d", r & 0xff);
|
||||
return (option_mask32 & FLAG_IGNORE_RETVAL) ? 0 : r;
|
||||
|
||||
#else /* insanity */
|
||||
|
@@ -772,7 +772,7 @@ static void run_script(const char *action, double offset)
|
||||
|
||||
/* Don't want to wait: it may run hwclock --systohc, and that
|
||||
* may take some time (seconds): */
|
||||
/*wait4pid(spawn(argv));*/
|
||||
/*spawn_and_wait(argv);*/
|
||||
spawn(argv);
|
||||
|
||||
unsetenv("stratum");
|
||||
|
@@ -271,7 +271,7 @@ void FAST_FUNC udhcp_run_script(struct dhcp_packet *packet, const char *name)
|
||||
argv[0] = (char*) client_config.script;
|
||||
argv[1] = (char*) name;
|
||||
argv[2] = NULL;
|
||||
wait4pid(spawn(argv));
|
||||
spawn_and_wait(argv);
|
||||
|
||||
for (curr = envp; *curr; curr++) {
|
||||
log2(" %s", *curr);
|
||||
|
@@ -160,13 +160,13 @@ static int run(char *argv[3], const char *param, struct in_addr *ip)
|
||||
}
|
||||
bb_info_msg(fmt, argv[2], argv[0], addr);
|
||||
|
||||
status = wait4pid(spawn(argv + 1));
|
||||
status = spawn_and_wait(argv + 1);
|
||||
if (status < 0) {
|
||||
bb_perror_msg("%s %s %s" + 3, argv[2], argv[0]);
|
||||
return -errno;
|
||||
}
|
||||
if (status != 0)
|
||||
bb_error_msg("script %s %s failed, exitcode=%d", argv[1], argv[2], status);
|
||||
bb_error_msg("script %s %s failed, exitcode=%d", argv[1], argv[2], status & 0xff);
|
||||
return status;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user