From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtpng3.m.smailru.net (smtpng3.m.smailru.net [94.100.177.149]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 61121469719 for ; Tue, 3 Mar 2020 14:38:56 +0300 (MSK) Date: Tue, 3 Mar 2020 14:38:53 +0300 From: Alexander Turenko Message-ID: <20200303113853.2gmoaph7zet7rzwo@tkn_work_nb> References: <20200302201227.31785-1-gorcunov@gmail.com> <20200302201227.31785-7-gorcunov@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200302201227.31785-7-gorcunov@gmail.com> Subject: Re: [Tarantool-patches] [PATCH 6/7] popen: handle setsid os specifics List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Cyrill Gorcunov Cc: tml On Mon, Mar 02, 2020 at 11:12:26PM +0300, Cyrill Gorcunov wrote: > On linux it is fine to call setsid right after > the vfork, in turn on bsd pgrp should be used. Can you refer a source of this information? I tried the following snippet on Mac OS and FreeBSD and it at least does not report an error: | #include | #include | | int | main() | { | if (setsid() == -1) { | perror("setsid"); | return 1; | } | return 0; | } $ cc setsid.c -o setsid $ echo 1 | ./setsid (Pipeline is to not be a session leader already, this will lead to EPERM.) > > Signed-off-by: Cyrill Gorcunov > --- > src/lib/core/popen.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/src/lib/core/popen.c b/src/lib/core/popen.c > index 6e5ca21bd..d41e9cfce 100644 > --- a/src/lib/core/popen.c > +++ b/src/lib/core/popen.c > @@ -839,8 +839,15 @@ popen_new(struct popen_opts *opts) > */ > if (opts->flags & POPEN_FLAG_SETSID) { > if (setsid() == -1) { > +#ifndef TARGET_OS_DARWIN > say_syserror("child: setsid failed"); > goto exit_child; > +#else > + if (setpgrp() == -1) { > + say_syserror("child: setpgrp failed"); > + goto exit_child; > + } > +#endif > } > } > > -- > 2.20.1 >