FAQ
I am using the daemonize (double-fork) code from the cookbook, and have
bumped into a strange issue. This is what my program is doing:

def main():
... useful things ...
os.popen('/usr/bin/lp -d printer1 %s' % (filename))

def daemonize(func):
"""cookbook recipe from
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66012"""

... cut 'n paste code ...

#Additional closing of stdio

sys.stdin.close()
sys.stdout.close()
sys.stderr.close()

# this is pretty obscure!
os.close(0)
os.close(1)
os.close(2)

if __name__ == '__main__':
daemonize(main)

The thing that's strange is that the call to lp never happens... if I
replace daemonize(main) with just main() it works as expected. Is there
some secret requirement on stdin/out for popen/spawn/system calls? I
have tried all three, and they all work when I don't double-fork, but
don't when I do. I can't figure this out at all, and it doesn't help
matters that the problem only occurs in a situation where it is very
hard to debug...

Thanks,

Mark

Search Discussions

Discussion Posts

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 4 | next ›
Discussion Overview
grouppython-list @
categoriespython
postedApr 20, '04 at 5:19p
activeApr 21, '04 at 3:10p
posts4
users3
websitepython.org

People

Translate

site design / logo © 2022 Grokbase