Hi,

I have similar problem.

I tried morbo, hypnotoad, running Mojolicious as root and regular user,
tried the 'reuse=0' flag, system perl 5.16.3 and custom perl 5.28.1
I also tried $^F=2 in startup script and just before system call
but it looks like O_CLOEXEC is not working (t/run/cloexec is ok) and
children spawned from Mojo app (either with system or backticks) inherit 
parent port *:3000

# ss -tlnp  |grep *:3000
LISTEN     0      128          *:3000                     *:*              
    
 
users:(("java",pid=18853,fd=3),("script/server",pid=12847,fd=3),("script/server",pid=1860,fd=3))

If I stop and try to start morbo it complains that the spawned process uses 
morbo's port:

$ morbo -w lib script/server .
Can't create listen socket: Address already in use at 
/home/user/perl5/lib/perl5/Mojo/IOLoop.pm line 124.

Can you recommend a way to auto close FDs (all or >2) for all spawned 
processes? 

Thank you,
Wes


On Thursday, 7 February 2019 15:06:03 UTC+1, Charlie Brady wrote:
>
>
> Yes, I do mean the HTTP port, and yes, Mojo would be handling that. It's 
> been noted before that FD_CLOEXEC doesn't seem to be working as expected 
> with Mojo (if indeed it is set by default by perl, as I have seen 
> asserted - it is disabled by default on sockets and fds in socket() and 
> open()). So maybe my expectation that Mojo should set FD_CLOEXEC is 
> misguided. 
>
> https://www.perlmonks.org/?node_id=1013743 
>
> On Wed, 6 Feb 2019, Nuno Mota wrote: 
>
>
> > After a lot of reading, I've managed to close all the sockets on the 
> fork 
> > itself, after setsid(). That did the trick. 
> > 
> > I'm assuming the fd you are talking is the HTTP port itself, because 
> that's 
> > the one hooked on my daemon. 
> > That would be Mojo handling it, am I wrong? 
> > 
> > Regards, 
> > Nuno Mota 
> > 
> > 
> > 
> > Charlie Brady <[email protected] <javascript:>> escreveu no 
> dia quarta, 
> > 6/02/2019 à(s) 15:36: 
> > 
> > > 
> > > You can find the file descriptor of the listen socket using 'fd' from 
> > > the daemon. 
> > > 
> > > https://mojolicious.org/perldoc/Mojo/Server/Daemon 
> > > 
> > > Make sure that the close-on-exec flag is set on that fd. That should 
> be 
> > > the default on perl, but maybe it isn't on your platform, or maybe 
> > > Mojolicious for some reason clears it... 
> > > 
> > > https://perldoc.perl.org/Fcntl.html 
> > > 
> > > On Tue, 5 Feb 2019, Nuno Mota wrote: 
> > > 
> > > > Hi, 
> > > > I'm having an issue with port bindings from my Mojolicious perl 
> daemon. 
> > > > 
> > > > The thing is, I issue a restart through Mojo, which then runs a bash 
> > > script 
> > > > that restarts a daemon. 
> > > > After this daemon starts, it's hooked on the Mojo HTTP port. Does 
> this 
> > > make 
> > > > any sense? 
> > > > 
> > > > perl      8883     root   16u  IPv4  91544      0t0  TCP *:8080 
> (LISTEN) 
> > > > daemon   9053     root   16u  IPv4  91544      0t0  TCP *:8080 
> (LISTEN) 
> > > > 
> > > > I've tried exec, system, backticks and nothing seems to properly 
> detach 
> > > the 
> > > > bash script from the Mojo port hooks. 
> > > > 
> > > > Regards, 
> > > > Nuno 
> > > > 
> > > > 
> > > 
> > 
> > 

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.

Reply via email to