From: Brian Candler Date: 2011-10-08T05:15:13+09:00 Subject: Re: ruby network question Paul M. wrote in post #1025617: > system "/usr/local/etc/rc.d/proftpd start" > > sockstat -4 -l then shows that the proftpd process is tied to the > listening port of the ruby program/daemon. > (It does the same when not running daemonised). > > > nobody proftpd 30996 1 tcp4 *:21 *:* > nobody proftpd 30885 3 tcp4 [hostIP]:844 *:* > root ruby 30826 3 tcp4 [hostIP]:844 *:* > > This doesn't affect the running of the ftp server or the ruby daemon, > but it means that i need to restart the various other daemons to release > the 844 socket. > > can anyone help? Looks like ruby not setting close_on_exec flag on your socket when doing fork/exec in system(), but I'm not sure how to get round this: http://stackoverflow.com/questions/1643304/how-to-set-close-on-exec-by-default But the simple way is to reimplement system() yourself by using fork and then exec within the child, and wait in the parent (it's pretty straightforward). Before you exec, close the listening socket. -- Posted via http://www.ruby-forum.com/.