This is causing significant problems for script portability between BSD and Linux.

I am on a CentOS 6.4 where this happens.

I have a nice compact test case:

bash -c "inotifywait -mcr . | sed s/CLOSE/z/"

ps uf and observe:

 \_ bash -c inotifywait -mcr . | sed s/CLOSE/z/
     \_ inotifywait -mcr .             
     \_ sed s/CLOSE/z/                 

Then, find the PID of the bash parent process, kill it.

Notice how the shell prompt has come back, indicating our shell's done waiting on its child.

But if you do anything on the filesystem to trigger inotify to report more events, it continues to dump to the terminal. On OS X, this does not happen because they would all be dead.

ps uf again. See that both inotifywait and sed are now children of init.

This seems totally wrong to me.

What does POSIX say about this?

closed as unclear what you're asking by Gilles, rahmu, user26112, jasonwryan, Renan Aug 5 '13 at 1:16

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • There's no reason why these processes should die. Are you sure you were killing the shell under OS X, and not the terminal emulator? – n.m. Aug 4 '13 at 15:07
  • Damn it. You're right. The reason why the child programs are killed (which happens to be desired) is elsewhere, it seems. Thanks. – Steven Lu Aug 4 '13 at 17:47

Browse other questions tagged or ask your own question.