3 ms·
So did I. Just the last week I needed a replacement for a container init that watches the process outputs and kills the process on timeout. Surprising, but I h
by drdaeman 4y ago
So did I.
Just the last week I needed a replacement for a container init that watches the process outputs and kills the process on timeout. Surprising, but I haven't found anything readily available, so I had to hack my own tiny program.
I haven't done much system programming any recently so my knowledge was kinda rusty. I knew the basics of what I should do - I had to wait on the child PID, watch out for the signals (because I'm running an init process, can't keep those zombies around), and work with the piped stdout/stderr fds. Sounds trivial, except that it's three completely independent APIs and those aren't files so select(1) is not my friend here. So I learned about signalfd and then learned how it's broken. Almost thought I have to run some threads but then I've learned about pselect(1) which seem to do the job.
Either way, "gosh, I'd wish I'd have Plan 9 instead of all this mess" was one of my thoughts that day.