]> eyrie.org Git - kerberos/kstart.git/commit
Set exit status if child stops via signal
authorAasif Versi <versi786@gmail.com>
Sat, 28 Aug 2021 15:04:43 +0000 (11:04 -0400)
committerAasif Versi <versi786@gmail.com>
Sat, 28 Aug 2021 15:04:43 +0000 (11:04 -0400)
commit7d55647cf4e9974b3ce0bb3b5556c5802169cad0
tree6f332c37ed66a1aa83bd118197b958df6bf8785d
parent44e1a8bb658d0a99c648547c410bcbe9911b9d90
Set exit status if child stops via signal

The current implementation of command_finish always calls WEXITSTATUS,
despite the man page for waitpid stating that WEXITSTATUS should only
be used if WIFEXITED returned true.

This change will set the exit status of k5start accordingly by either
using WTERMSIG if WIFSIGNALED returns true, and using WEXITSTATUS if
WIFEXITETED returns true. This means that the user can check the exit
status of the command running under k5start and know if the command
failed. Looking at the following example, in the previous code, the
command would print 0, now it will print 143. This will match the
functionality of bash [0].

$ k5start -f ./user.keytab -- sh -c 'kill $$'; echo $?
143
$ sh -c 'kill $$'; echo $?
143

This also makes a minor change by only setting the status if it is a
non-null pointer.

[0]: https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html
tests/k5start/basic-t
util/command.c