Ticket #1799 (closed bug: fixed)

Opened 9 months ago

Last modified 9 months ago

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 development
Cc: Blocked By:
Platform: All Blocking:

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

  Changed 9 months ago by bonefish

  • owner changed from axeld to bonefish
  • status changed from new to assigned

  Changed 9 months ago by jackburton

This seems to be fixed.

  Changed 9 months ago by jackburton

No, sorry, I talked too fast. It's just not easily reproducible.

  Changed 9 months ago by bonefish

Yep, my changes in r24041 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 r24042 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.

  Changed 9 months ago by bonefish

  • status changed from assigned to closed
  • resolution set to fixed

Fixed in r24335.

follow-up: ↓ 7   Changed 9 months ago by jonas.kirilla

in reply to: ↑ 6   Changed 9 months ago by bonefish

Replying to jonas.kirilla:

I can still reproduce it with r24336. :/

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.

Note: See TracTickets for help on using tickets.