Hello! On Thu, Nov 23, 2017 at 07:44:57PM +0300, Igor Sysoev wrote:
> > On 23 Nov 2017, at 19:28, Gena Makhomed <[email protected]> wrote: > > > > Кстати, Lennart Poettering нашел еще одну ошибку в исходниках nginx: > > https://lists.freedesktop.org/archives/systemd-devel/2017-November/039832.html > > Интересно, откуда он это придумал про двойной fork()? > > Во FreeBSD используется только один fork() что в 2017 году: > https://svnweb.freebsd.org/base/head/lib/libc/gen/daemon.c?revision=326025&view=co > что в 1994: > https://svnweb.freebsd.org/base/head/lib/libc/gen/daemon.c?revision=1573&view=co Двойной форк нужен на Линуксе, чтобы случайно не получить себе обратно controlling terminal. Документировано, например, тут в man daemon(3) у glibc, http://man7.org/linux/man-pages/man3/daemon.3.html: The GNU C library implementation of this function was taken from BSD, and does not employ the double-fork technique (i.e., fork(2), setsid(2), fork(2)) that is necessary to ensure that the resulting daemon process is not a session leader. Instead, the resulting daemon is a session leader. On systems that follow System V semantics (e.g., Linux), this means that if the daemon opens a terminal that is not already a controlling terminal for another session, then that terminal will inadvertently become the controlling terminal for the daemon. Смысла это делать в nginx'е - скорее нет, IMHO. -- Maxim Dounin http://mdounin.ru/ _______________________________________________ nginx-ru mailing list [email protected] http://mailman.nginx.org/mailman/listinfo/nginx-ru
