* Dag-Erling Sm??rgrav <d...@des.no> [090527 06:10] wrote:
> Yuri <y...@rawbw.com> writes:
> > I don't have strong opinion for or against "memory overcommit". But I
> > can imagine one could argue that fork with intent of exec is a faulty
> > scenario that is a relict from the past. It can be replaced by some
> > atomic method that would spawn the child without ovecommitting.
> 
> You will very rarely see something like this:
> 
> if ((pid = fork()) == 0) {
>         execve(path, argv, envp);
>         _exit(1);
> }
> 
> Usually, what you see is closer to this:
> 
> if ((pid = fork()) == 0) {
>         for (int fd = 3; fd < getdtablesize(); ++fd)
>                 (void)close(fd);
>         execve(path, argv, envp);
>         _exit(1);
> }

I'm probably missing something, but couldn't you iterate 
in the parent setting the close-on-exec flag then vfork?

I guess that wouldn't work for threads AND you'd have to
undo it after the fork if you didn't want to retain that
behavior?

thanks,
-Alfred
_______________________________________________
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"

Reply via email to