<s> '''<STR_LIT>''' <EOL> import logging <EOL> import os <EOL> import sys <EOL> log = logging . getLogger ( __name__ ) <EOL> def daemonize ( target , stream = None ) : <EOL> """<STR_LIT>""" <EOL> pid = os . fork ( ) <EOL> if pid > <NUM_LIT:0> : <EOL> return <EOL> os . chdir ( "<STR_LIT:/>" ) <EOL> pid = os . fork ( ) <EOL> if pid > <NUM_LIT:0> : <EOL> sys . exit ( <NUM_LIT:0> ) <EOL> sys . stdout . flush ( ) <EOL> sys . stderr . flush ( ) <EOL> si = open ( '<STR_LIT>' , '<STR_LIT:r>' ) <EOL> so = open ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> se = open ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> os . dup2 ( si . fileno ( ) , sys . stdin . fileno ( ) ) <EOL> os . dup2 ( so . fileno ( ) , sys . stdout . fileno ( ) ) <EOL> os . dup2 ( se . fileno ( ) , sys . stderr . fileno ( ) ) <EOL> if stream : <EOL> sys . stdin = stream <EOL> sys . stderr = stream <EOL> target ( ) <EOL> sys . exit ( <NUM_LIT:0> ) </s>
