Here's my first patch submission, so anything that is odd or should be fixed please let me know. That goes for either how I've submitted it or any coding issues. Log Message: wineclipsrv runs as a daemon (closes stdout/stderr, no controlling terminal, session group leader). Prevents wine from hanging on open stdout/stderr (bug #323)
Index: wineclipsrv.c =================================================================== RCS file: /home/wine/wine/windows/x11drv/wineclipsrv.c,v retrieving revision 1.7 diff -u -r1.7 wineclipsrv.c --- wineclipsrv.c 2001/10/14 16:18:54 1.7 +++ wineclipsrv.c 2002/03/05 06:17:49 @@ -174,6 +174,7 @@ * Prototypes */ +int RunAsDaemon( void ); BOOL Init(int argc, char **argv); void TerminateServer( int ret ); int AcquireSelection(); @@ -195,6 +196,12 @@ { XEvent event; + if ( RunAsDaemon() == -1 ) + { + ERR("could not run as daemon\n"); + exit(1); + } + if ( !Init(argc, argv) ) exit(0); @@ -218,6 +225,39 @@ /************************************************************************** + * RunAsDaemon() + */ +int RunAsDaemon( void ) +{ + pid_t pid; + int i; + + /* fork child process and let parent exit ; gets rid of original PID */ + pid = fork(); + switch ( pid ) + { + case -1: + ERR("fork failed\n"); + return(-1); + break; + case 0: + exit(0); + break; + } + + /* below is child process w/ new PID, set as session leader */ + setsid(); + + /* close stdin,stdout,stderr and file descriptors (overkill method) */ + for ( i = 0; i < 256 ; i++ ) + close(i); + + TRACE("now running as daemon...\n"); + return 0; +} + + +/************************************************************************** * Init() * Initialize the clipboard server */ @@ -337,6 +377,7 @@ return TRUE; } + /**************************************************************************