ChildProcess and zombies on linux


#1

Sometimes, not that very often, but sometime, scripts i run using ChildProcess turn into zombies.

The tricky part is that my scripts read data from a OneWire devices that's reporting to the /sys using a special driver in Linux. That script might hang sometimes due to the fact that the OneWire bus is not that reliable always. The code i use is placed within the run() method of a special thread (so i don't block when reading the output from the script). Can anyone tell me if there is something wrong with that, or should i blame JUCE's ChildProcess implementation on Linux (POSIX?)

            if (childProc.start(command))
            {
                if (childProc.waitForProcessToFinish(getTimeout()))
                {
                    processCommandOutput(childProc.readAllProcessOutput().trim());
                }
                else
                {
                    _WRN("["+getName()+"] timeout");

                    if (!childProc.kill())
                    {
                        _WRN("["+getName()+"] can't kill child process");
                    }
                }
            }
            else
            {
                _WRN("["+getName()+"] failed to start child process");
            }

#2

By wild guessing I would rather blame this on the Kernel module implementing the OneWire bus.

Stuff that blocks in kernel space out of whichever reason can have all sorts of weird side effects on user processes reading pipes associated with file based Kernel modules.


#3

Well i was hoping to hand off most of the GPIO/I2C work to the kernel drivers (i found most of drivers i need for my sensors).

This is all based on reading /sys files, i can try to write a thread that will read that file and a watcher thread to see if the reading thread hangs, but if a script with a "cat" command goes zombie, what will happen to a thread. Also i saw that JUCE calls jassert when killing a thread by force, i still don't know why (is that illegal ?)

What's the better solution here, anyone has any experience ? I trust kernel drivers more then i trust my own code, but maybe userspace is safer in this case (i can try to access most of the sensors using wiringPi and whatever userspace stuff i can find)