[sudo-users] Is it okay to fork() in a sudo i/o plugin?
Todd C. Miller
Todd.Miller at sudo.ws
Mon Feb 4 21:00:29 MST 2019
On Mon, 04 Feb 2019 19:37:13 -0600, Bryan Christ wrote:
> I'm writing a plug-in for sudo using the plugin API. Since the logging
> facility of the plug-in will push data to a remote server, I want to avoid
> potential blocking situations. Is it reasonable to fork() from an I/O
> plugin? Obviously I can't install a handler for sigchld to reap processes
> so I perceive that to be a bit of a problem right out of the gate unless
> sudo already has a handler that I can count on to do that.
When do you want to do the fork? You could use a single child
process that you communicate with over a socketpair in the plugin
and wait for the child in the plugin's close function. If you do
non-blocking I/O in the child and buffer things until the remote
end can consume them you shouldn't have to worry about blocking.
- todd
More information about the sudo-users
mailing list