[sudo-users] Is it okay to fork() in a sudo i/o plugin?

Bryan Christ bryan.christ at gmail.com
Mon Feb 4 21:07:41 MST 2019


That certainly a reasonable approach.  At what point is it safe for the
plugin to fork()?

On Mon, Feb 4, 2019, 22:00 Todd C. Miller <Todd.Miller at sudo.ws wrote:

> 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