[OpenWrt-Devel] [PATCH] procd: show process's exit code
Petr Štetiar
ynezz at true.cz
Mon Jan 20 18:05:04 EST 2020
ondrej.votava at cvut.cz <ondrej.votava at cvut.cz> [2020-01-20 10:53:05]:
Ahoj,
this comment(if it's really needed and I doubt that) should go into commit
description, self-explaining code is prefered, everybody knows how to use man
pages already or knows how to use `git blame`.
> + /*
> + According to man waitpid(2) exit codes might be:
> + 0 -- everything is OK
> + SIGNALLED -- 1 - 64 - and since we want the same behavior as SHELL, we add 128
Why is having same behavior as shell desirable? Having answer to that question
in the commit description would probably help more.
> + @see http://tldp.org/LDP/abs/html/exitcodes.html
> + 256 - 65536 -- regular exit, strip the bottom byte with WEXITSTATUS macro.
> + @see man waitpid(2)
> + */
> + in->exit_code = WIFEXITED(ret) ? WEXITSTATUS(ret) : WIFSIGNALED(ret) ? 128 + WTERMSIG(ret) : 1;
I'm having hard time reviewing this line, probably something like bellow
(untested) would work as well:
static int process_wait_result(int status)
{
int ret;
ret = WEXITSTATUS(status);
if (WIFSIGNALED(status))
ret = 128 + WTERMSIG(status);
return ret;
}
in->exit_code = process_wait_result(ret);
-- ynezz
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel
More information about the openwrt-devel
mailing list