From: Jan S. <jst...@re...> - 2011-12-14 11:06:02
|
This test occasionally hangs on some machines. The hang has been observed on some single CPU ones. pipeio code is using signal(2), setting by default SA_RESTART flag, which is also the case for SIGCHLD. If last child manages to exit while parent is still at open(), parent gets SIGCHLD and open() is restarted. At this point test hangs. Here's strace output from parent point of view: === snip === brk(0) = 0x11bb000 brk(0x11dd000) = 0x11dd000 getpid() = 18826 stat("tpipe.18826", 0x7fff89e1d410) = -1 ENOENT (No such file or directory) mknod("tpipe.18826", S_IFIFO|0777) = 0 rt_sigaction(SIGCHLD, {0x400a54, [CHLD], SA_RESTORER|SA_RESTART, 0x354aa32a20}, {SIG_DFL, [], 0}, 8) = 0 clone(child_stack=0, flags=CLONE_CHILD_CLEARTID| CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7f53b9ddd9d0) = 18827 fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 3), ...}) = 0 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f53b9de5000 open("tpipe.18826", O_RDONLY ) = ? ERESTARTSYS (To be restarted) --- SIGCHLD (Child exited) @ 0 (0) --- wait4(-1, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0, NULL) = 18827 rt_sigreturn(0xffffffffffffffff) = 2 open("tpipe.18826", O_RDONLY === /snip === This patch is introducing semaphore, which prevents children from exiting until parent completes open(). It also adds timed wait, so parent waits for children to exit before it deletes pipe and semaphore. Signed-off-by: Jan Stancek <jst...@re...> --- testcases/kernel/ipc/pipeio/pipeio.c | 37 ++++++++++++++++++++++++++++++++- 1 files changed, 35 insertions(+), 2 deletions(-) |