Rajul Vora
2013-Feb-28 21:35 UTC
[Puppet Users] Does Puppet agent close file descriptors on exec / service start?
I have a start/stop script which does something like this for the start command: program1 & program2 start program1 further launches other processes. I have used ''exec'' and ''service'' resources to start/stop but either way I see a /tmp puppet related file descriptor still open in the resulting child processes. The puppet file has subsequently been deleted after the Puppet run ended. # lsof | grep delete python 10144 root 2u REG 202,1 12069 25275 /tmp/puppet20130228-1114-h76qq2-0 (deleted) mongrel2 10150 root 2u REG 202,1 12069 25275 /tmp/puppet20130228-1114-h76qq2-0 (deleted) python 10212 root 2u REG 202,1 12069 25275 /tmp/puppet20130228-1114-h76qq2-0 (deleted) Here, program1 is the first python command with pid=10144 which has spawned the 2nd python command with pid=10212. program2 is the mongrel2 command with pid=10150. Puppet server version is: puppetmaster 3.0.2-1puppetlabs1 Puppet agent version is: puppet 3.0.2-1puppetlabs1 Any pointers on how to prevent this file descriptor leakage? Rajul -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
jcbollinger
2013-Mar-01 15:15 UTC
[Puppet Users] Re: Does Puppet agent close file descriptors on exec / service start?
On Thursday, February 28, 2013 3:35:24 PM UTC-6, Rajul Vora wrote:> > > I have a start/stop script which does something like this for the start > command: > > program1 & > program2 start > > > program1 further launches other processes. > > I have used ''exec'' and ''service'' resources to start/stop but either way I > see a /tmp puppet related file descriptor still open in the resulting child > processes. The puppet file has subsequently been deleted after the Puppet > run ended. > > > # lsof | grep delete > python 10144 root 2u REG 202,1 12069 25275 > /tmp/puppet20130228-1114-h76qq2-0 (deleted) > mongrel2 10150 root 2u REG 202,1 12069 25275 > /tmp/puppet20130228-1114-h76qq2-0 (deleted) > python 10212 root 2u REG 202,1 12069 25275 > /tmp/puppet20130228-1114-h76qq2-0 (deleted) > > Here, program1 is the first python command with pid=10144 which has > spawned the 2nd python command with pid=10212. program2 is the mongrel2 > command with pid=10150. > > Puppet server version is: > puppetmaster 3.0.2-1puppetlabs1 > > Puppet agent version is: > puppet 3.0.2-1puppetlabs1 > > Any pointers on how to prevent this file descriptor leakage? > >If you don''t want the child processes to hold open file descriptors inherited from the parent then it''s your responsibility to close them. In particular, you typically want to close or redirect the standard streams (fds 0, 1, and 2) of such child processes when they are intended to run independently of the parent. Since you appear to be launching these processes via a shell, you could consider this: program1 </dev/null >/dev/null 2>&1 & program2 (There are other alternatives, too, including some that will close the standard streams instead of redirecting to /dev/null.) John -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.