mandriva

Ticket #809 (closed defect: fixed)

Opened 2 years ago

Last modified 21 months ago

daemon() lacks closing the service standard stream

Reported by: nrueff Owned by: oroussy
Priority: Highest Milestone: 1.2.5
Component: general Version: 1.2.4
Severity: Blocker Keywords:
Cc:

Description

The daemon() function do not seems to replace the daemon stdin, stdout and stderr by /dev/null :

etch:~# ls -l /proc/`pidof -s -x pulse2-inventory-server`/fd
total 3
lrwx------ 1 root root 64 2010-03-01 16:35 0 -> socket:[8740]
l-wx------ 1 root root 64 2010-03-01 16:35 3 -> /var/log/mmc/pulse2-inventory-server.log
lrwx------ 1 root root 64 2010-03-01 16:35 4 -> socket:[8737]

In fact, I'm not even sure that existing file descriptors are cleanly closed. here is a working example (to be introduced after the second fork() :

for fd in range(0, 1024):
    try:
        os.close(fd)
    except OSError:
        pass

os.open(os.devnull, os.O_RDWR)
os.dup2(0, 1)
os.dup2(0, 2)

IRL, 1024 should be replaced by resource.RLIMIT_NOFILE, logging reconfigured after, and a check should be done around os.devnull (introduced in python 2.4), but you got the idea.

Here is what you may obtain after :

etch:~# ls /proc/`pidof -s -x pulse2-inventory-server`/fd -l
total 6
lrwx------ 1 root root 64 2010-03-01 17:06 0 -> /dev/null
lrwx------ 1 root root 64 2010-03-01 17:06 1 -> /dev/null
lrwx------ 1 root root 64 2010-03-01 17:06 2 -> /dev/null
l-wx------ 1 root root 64 2010-03-01 17:06 3 -> /var/log/mmc/pulse2-inventory-server.log
lrwx------ 1 root root 64 2010-03-01 17:06 4 -> socket:[10568]
lrwx------ 1 root root 64 2010-03-01 17:06 5 -> socket:[10570]

Attachments

Change History

Changed 21 months ago by oroussy

  • status changed from new to closed
  • resolution set to fixed
  • milestone changed from Dispatch Me ! to 1.2.5

corrected in :

  • mmc-projects r6878 - pulse2/server/trunk/services/bin
  • pulse2-inventory-server r226 - branches/PULSE_1_2_5/bin

Add/Change #809 (daemon() lacks closing the service standard stream)

Author



Action
as closed
Next status will be 'reopened'
 
Note: See TracTickets for help on using tickets.