]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
script: add debug messages around waitpid()
authorKarel Zak <kzak@redhat.com>
Wed, 9 Oct 2019 13:07:49 +0000 (15:07 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 9 Oct 2019 13:07:49 +0000 (15:07 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
lib/pty-session.c
tests/ts/script/buffering-race

index d9cfad2875ac0c63c7f0846788c79223f5db9301..10eb462d28b4a7ed3358145f355d7197e43e6492 100644 (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);
                }
index 0e4b2b9772870ed0cded6ee05ef405047d9e784b..51421faeb676a8f9fcd6469082a7c4eaab54ffaf 100755 (executable)
@@ -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