Commit 7c187717 authored by Jason Phillips's avatar Jason Phillips Committed by Alexandre Julliard

Make wineclipsrv run as a daemon (close stdout/stderr, no controlling

terminal, session group leader).
parent 46a9db64
......@@ -188,6 +188,7 @@ static const char * const event_names[] =
* Prototypes
*/
int RunAsDaemon( void );
BOOL Init(int argc, char **argv);
void TerminateServer( int ret );
int AcquireSelection();
......@@ -209,6 +210,12 @@ int main(int argc, char **argv)
{
XEvent event;
if ( RunAsDaemon() == -1 )
{
ERR("could not run as daemon\n");
exit(1);
}
if ( !Init(argc, argv) )
exit(0);
......@@ -232,6 +239,36 @@ int main(int argc, char **argv)
/**************************************************************************
* RunAsDaemon()
*/
int RunAsDaemon( void )
{
int i;
/* fork child process and let parent exit ; gets rid of original PID */
switch( fork() )
{
case -1:
ERR("fork failed\n");
return(-1);
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
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment