Skip to contentSkip to conversation

tst_mkfs: ignorce SIGCHLD for calling system function

PATCH In review [email protected] 2 participants 3 messages Nov 11, 2014 1 message not in the archive Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tst_mkfs: ignorce SIGCHLD for calling system function

From: George Wang <[email protected]>

function(3) system will raise the SIGCHILD signal to parent process, which should cause the test case failed(especially to btrfs). ignorce it before calling the system function and restore it after the calling.

---
 lib/tst_mkfs.c | 2 ++
 1 file changed, 2 insertions(+)
lib/tst_mkfs.c +2 -0
index 5eb3392..9a63863 100644
@@ -45,11 +45,13 @@ void tst_mkfs(void (cleanup_fn)(void), const char *dev,
 		/*
 		 * The -f option was added to btrfs-progs v3.12
 		 */
+		void *old_handler = signal(SIGCHLD, SIG_DFL);	
 		if (system("mkfs.btrfs 2>&1 | grep '\\-f ' >/dev/null") == 0) {
 			tst_resm(TINFO, "Appending '-f' flag to mkfs.%s",
 				fs_type);
 			argv[pos++] = "-f";
 		}
+		signal(SIGCHLD, old_handler);
 	}
 
 	if (fs_opts) {
Signature · 13 lines
1.9.3


------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://pubads.g.doubleclick.net/gampad/clk?id=154624111&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
#1 lore raw

Hi!

Quoted 3 lines

function(3) system will raise the SIGCHILD signal to parent process, which should cause the test case failed(especially to btrfs). ignorce it before calling the system function and restore it after the calling.

Which test was failing because of this?

Generally testcases should set the correct
tst_sig(FORK, ...) / tst_sig(NOFORK, ...)
even when they use system() or fork() indirectly.

Signature · 13 lines
Cyril Hrubis
[email protected]

------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://pubads.g.doubleclick.net/gampad/clk?id=154624111&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

A message that is not in the archive (sent off-list or not yet received): [email protected]

#3 lore raw

Hi!

Quoted 24 lines

Hi,

function "void tst_mkfs(...)" is used by such flollowing test cases:

testcases/kernel/syscalls/../

    creat06
    fchown04
    fchown04_16
    inotify_03
    ichown03
    ichown03_16
    link08
    linkat02
    mkdir03
    mkdirat02
    mknod07
    mknodat02
    mount01
    mount06
    rename11
    reanameat01
    rmdir02
    umount01
Quoted 4 lines

And all of these test cases " tst_sig(NOFORK, DEF_HANDLER, cleanup);" before calling tst_mkfs. So when the tst_mkfs calls "if (system("mkfs.btrfs 2>&1 | grep '\\-f ' >/dev/null") == 0) ", the SIGCHLD will be caught by parent process, and all of the tests will fail.
In my opinion, change the tst_mkfs is the better way.

Hmm, we have that trick allready in tst_run_cmd() but that cannot be used because it fails on non-zero exit value.

What I would like to avoid is spreading signal() calls around the library code. So the best solution may be to add a tst_system() to tst_run_cmd.c which would behave like system() but will also swap the signal handlers (and will include the very same comment explaining why we do that as we have in the tst_run_cmd.c). Then we can use the tst_system() internally in the test library.

Signature · 13 lines
Cyril Hrubis
[email protected]

------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://pubads.g.doubleclick.net/gampad/clk?id=154624111&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list