script: add debug messages around waitpid()

Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
Karel Zak 2019-10-09 15:07:49 +02:00
parent 406fb25387
commit 125314c04a
2 changed files with 5 additions and 2 deletions

View File

@ -327,13 +327,14 @@ void ul_pty_wait_for_child(struct ul_pty *pty)
if (pty->child == (pid_t) -1)
return;
DBG(SIG, ul_debug("waiting for child"));
DBG(SIG, ul_debug("waiting for child [child=%d]", (int) pty->child));
if (ul_pty_is_running(pty)) {
/* wait for specific child */
options = WNOHANG;
for (;;) {
pid = waitpid(pty->child, &status, options);
DBG(SIG, ul_debug(" waitpid done [rc=%d]", (int) pid));
if (pid != (pid_t) - 1) {
if (pty->callbacks.child_die)
pty->callbacks.child_die(
@ -346,6 +347,7 @@ void ul_pty_wait_for_child(struct ul_pty *pty)
} else {
/* final wait */
while ((pid = wait3(&status, options, NULL)) > 0) {
DBG(SIG, ul_debug(" wait3 done [rc=%d]", (int) pid));
if (pid == pty->child) {
if (pty->callbacks.child_die)
pty->callbacks.child_die(
@ -391,6 +393,7 @@ static int handle_signal(struct ul_pty *pty, int fd)
pty->child);
if (pty->child <= 0) {
DBG(SIG, ul_debugobj(pty, " no child, setting leaving timeout"));
pty->poll_timeout = 10;
timerclear(&pty->next_callback_time);
}

View File

@ -20,7 +20,7 @@ ts_init "$*"
ts_check_test_command "$TS_CMD_SCRIPT"
$TS_CMD_SCRIPT -c "echo Hallo World" /dev/null </dev/null >$TS_OUTPUT
SCRIPT_DEBUG=all ULPTY_DEBUG=all $TS_CMD_SCRIPT -c "echo Hallo World" /dev/null </dev/null >$TS_OUTPUT
ts_finalize