Skip to contentSkip to conversation

test: Disown child pid for cleaner stderr

PATCH In review [email protected] 3 participants 3 messages Oct 31, 2024 – Nov 1, 2024

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 test: Disown child pid for cleaner stderr

From: Eugene Loh <[email protected]>

The shell can report when a job is killed, potentially polluting stderr and thereby mismatching the results file.

When a job is killed at the end of test, appearance of such reports may depend on timing details: does the parent test or the child job terminate first?

Many tests deal with this problem by disowning child jobs.

Disown jobs in a few more possibly problematic tests.

---
 test/unittest/usdt/tst.dlclose1.sh             | 1 +
 test/unittest/usdt/tst.enable_pid.sh           | 2 ++
 test/unittest/usdt/tst.exec-dof-replacement.sh | 1 +
 test/unittest/usdt/tst.nusdtprobes.sh          | 1 +
 4 files changed, 5 insertions(+)
test/unittest/usdt/tst.dlclose1.sh +1 -0
index ee4d95f3b..b65e4de5d 100755
@@ -200,6 +200,7 @@ function mywait() {
 
 ./main > myfile.txt &
 pid=$!
+disown %+
 echo started pid $pid
 
 mywait 6 "started"  myfile.txt # wait for process to start
test/unittest/usdt/tst.enable_pid.sh +2 -0
index 91923014d..bbb7680c4 100755
@@ -142,8 +142,10 @@ fi
 
 ./main >& out.1 &
 pid1=$!
+disown %+
 ./main >& out.2 &
 pid2=$!
+disown %+
 
 #
 # Run DTrace with different pid probes, each case is its own "epoch":
test/unittest/usdt/tst.exec-dof-replacement.sh +1 -0
index 9f30bbfcc..f9cf6bdb2 100755
@@ -81,6 +81,7 @@ fi
 
 ./test1 &
 PROC=$!
+disown %+
 
 # Wait for the exec, then list all the target's probes.
 # We cannot use pure dtrace to do this because it doesn't check
test/unittest/usdt/tst.nusdtprobes.sh +1 -0
index 50f18a6ca..4b5050ff9 100755
@@ -121,6 +121,7 @@ for nusdt in "" "-xnusdtprobes=40" "-xnusdtprobes=39"; do
 		for (( immbr = 0; immbr < $nmmbrs; immbr++ )); do
 			./main &
 			pids[$immbr]=$!
+			disown %+
 			for j in `seq 0 9`; do
 				echo testprov${pids[$immbr]} main main foo$j >> check.txt
 			done
Signature · 1 line
2.43.5
Reviewed-by on v2 1/1
#1 lore raw
Quoted 9 lines · On Thu, Oct 31, 2024 at 12:49:06AM -0400, [email protected] wrote:

From: Eugene Loh <[email protected]>

The shell can report when a job is killed, potentially polluting stderr and thereby mismatching the results file.

When a job is killed at the end of test, appearance of such reports may depend on timing details: does the parent test or the child job terminate first?

Quoted 5 lines

Many tests deal with this problem by disowning child jobs.

Disown jobs in a few more possibly problematic tests.

Quoted 61 lines
---
 test/unittest/usdt/tst.dlclose1.sh             | 1 +
 test/unittest/usdt/tst.enable_pid.sh           | 2 ++
 test/unittest/usdt/tst.exec-dof-replacement.sh | 1 +
 test/unittest/usdt/tst.nusdtprobes.sh          | 1 +
 4 files changed, 5 insertions(+)
test/unittest/usdt/tst.dlclose1.sh +1 -0
index ee4d95f3b..b65e4de5d 100755
@@ -200,6 +200,7 @@ function mywait() {
 
 ./main > myfile.txt &
 pid=$!
+disown %+
 echo started pid $pid
 
 mywait 6 "started"  myfile.txt # wait for process to start
test/unittest/usdt/tst.enable_pid.sh +2 -0
index 91923014d..bbb7680c4 100755
@@ -142,8 +142,10 @@ fi
 
 ./main >& out.1 &
 pid1=$!
+disown %+
 ./main >& out.2 &
 pid2=$!
+disown %+
 
 #
 # Run DTrace with different pid probes, each case is its own "epoch":
test/unittest/usdt/tst.exec-dof-replacement.sh +1 -0
index 9f30bbfcc..f9cf6bdb2 100755
@@ -81,6 +81,7 @@ fi
 
 ./test1 &
 PROC=$!
+disown %+
 
 # Wait for the exec, then list all the target's probes.
 # We cannot use pure dtrace to do this because it doesn't check
test/unittest/usdt/tst.nusdtprobes.sh +1 -0
index 50f18a6ca..4b5050ff9 100755
@@ -121,6 +121,7 @@ for nusdt in "" "-xnusdtprobes=40" "-xnusdtprobes=39"; do
 		for (( immbr = 0; immbr < $nmmbrs; immbr++ )); do
 			./main &
 			pids[$immbr]=$!
+			disown %+
 			for j in `seq 0 9`; do
 				echo testprov${pids[$immbr]} main main foo$j >> check.txt
 			done
Signature · 1 line
2.43.5
Reviewed-by on v2 1/1
#2 lore raw
In reply to [email protected]

On 31 Oct 2024, eugene loh verbalised:

Quoted 9 lines

From: Eugene Loh <[email protected]>

The shell can report when a job is killed, potentially polluting stderr and thereby mismatching the results file.

When a job is killed at the end of test, appearance of such reports may depend on timing details: does the parent test or the child job terminate first?

Quoted 5 lines

Many tests deal with this problem by disowning child jobs.

Disown jobs in a few more possibly problematic tests.

(My only reason for not doing that already was that I mistakenly thought disown didn't do anything in noninteractive shells.)

Signature · 1 line
NULL && (void)