#1799 closed bug (fixed)
sh: child setpgid (216 to 215): Operation not allowed
Reported by: | jonas.kirilla | Owned by: | bonefish |
---|---|---|---|
Priority: | normal | Milestone: | R1 |
Component: | System/Kernel | Version: | R1/pre-alpha1 |
Keywords: | Cc: | ||
Blocked By: | Blocking: | ||
Platform: | All |
Description
setpgid() often fails for shell builtin 'echo' when using pipes.
~>echo "blarg" | wc sh: child setpgid (216 to 215): Operation not allowed 1 1 6 ~>echo "blarg" | wc sh: child setpgid (218 to 217): Operation not allowed 1 1 6 ~>echo "blarg" | wc 1 1 6 ~>echo "blarg" | w 1 1 6 ~>echo "blarg" | wc 1 1 6 ~>echo "blarg" | wc sh: child setpgid (226 to 225): Operation not allowed 1 1 6 ~>echo "blarg" | wc sh: child setpgid (228 to 227): Operation not allowed 1 1 6
Maybe it's got something to do with http://dev.haiku-os.org/changeset/22185
Change History (7)
comment:1 by , 17 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:2 by , 17 years ago
comment:4 by , 17 years ago
Yep, my changes in hrev24041 made it less likely (the race conditions in wait_for_child() are gone), but it won't be fixed until the TODO I added in hrev24042 is dealt with (keeping process groups with only zombies in them alive until all zombies are reaped). Will do that when I find a little more time.
follow-up: 7 comment:6 by , 17 years ago
I can still reproduce it with hrev24336. :/
http://www.kirilla.com/haiku/r24336-1.png http://www.kirilla.com/haiku/r24336-2.png
comment:7 by , 17 years ago
Replying to jonas.kirilla:
I can still reproduce it with hrev24336. :/
As it looks to me, this only happens when hitting Ctrl-C while the shell is in the middle of setting up the pipe. For the first process setpgid() has already been done and it has been given the terminal. Hitting Ctrl-C right then will cause a SIGINT to be sent to the new process group and kill all child processes that have already joined the group. Since the shell blocks SIGCHLD only while creating a child process, as soon as it is unblocked, the SIGCHLD handler is invoked, which does a waitpid() and thus causes the process group to be deleted for good. Afterwards the shell continues to create the remaining processes of the pipe and setpgid() will fail for them.
This seems to be a (design?) problem in bash rather than a bug in Haiku. At least I don't see what we could possibly be doing wrong. The original bug seems to be fixed at any rate.
This seems to be fixed.