std.process - POSIX specific callback

Steven Schveighoffer schveiguy at yahoo.com
Thu Jun 6 10:18:14 PDT 2013


On Thu, 06 Jun 2013 12:05:14 -0400, nazriel <spam at dzfl.pl> wrote:

> Would it be possible to add to std.process.Config POSIX specific  
> callback which would be called after fork()?
>
> It is currently main blocker in switching dpaste-be from handmade  
> process handling module to std.process.
>
> It could look something like this.
>
> struct Config {
>       // current fields
>       void delegate() posixCallback;
> }
>
> // ...
>
> int i = fork();
> if (i > 0)
> {
> //...
>     if (config.posixCallback !is null)
>          config.posixCallback();
> //...
> }
>
> Such construct would allow for various child process manipulation, for  
> instance
> dropping root privileges or setting limits via setrmlimit.
>
> Example:
>
> config.posixCallback = {
>      setguid(ourGUID);
>      setgroups(ourGROUPS);
>      setuid(ourUID);
>
>      setrmlimit(NFORK, 123);
> };
>
>
> AFAIK we already have Windows specific flag related to spawning console  
> for GUI apps.
>
> I can make pull request ASAP when I get reasonable name for field.
>
> Lars? ;)

I agree with the ability, but not with the interface.  If this is to be  
done, it should be at a lower level, not inside config.  Keep in mind that  
std.process is generalized for both Windows and Posix, with very minor  
differences.

-Steve


More information about the Digitalmars-d mailing list