wait child process but get error: 'pid is not a child of this shell'

后端 未结 3 1242
一个人的身影
一个人的身影 2020-12-30 01:08

I write a script to get data from HDFS parrallel,then I wait these child processes in a for loop, but sometimes it returns \"pid is not a child of this shell\". sometimes, i

3条回答
  •  独厮守ぢ
    2020-12-30 01:11

    If you're running this in a container of some sort, the condition apparently can be caused by a bug in bash that is easier to encounter in a containerized envrionment.

    From my reading of the bash source (specifically see comments around RECYCLES_PIDS and CHILD_MAX in bash-4.2/jobs.c), it looks like in their effort to optimize their tracking of background jobs, they leave themselves vulnerable to PID aliasing (where a new process might obscure the status of an old one); to mitigate that, they prune their background process history (apparently as mandated by POSIX?). If you should happen to want to wait on a pruned process, the shell can't find it in the history and assumes this to mean that it never knew about it (i.e., that it "is not a child of this shell").

提交回复
热议问题