When the Wine server launches, it creates a Unix socket through open_master_socket(),all Wine processes launched later connects to the Wine server using this socket,here is the code from server/request.c,open_master_socket():
771 if (!foreground)
772 {
773 if (pipe( sync_pipe ) == -1) fatal_perror( "pipe" );
774 pid = fork();
775 switch( pid )
776 {
777 case 0: /* child */
778 setsid();
779 close( sync_pipe[0] );
780
781 acquire_lock();
782
783 /* close stdin and stdout */
784 dup2( fd, 0 );
785 dup2( fd, 1 );
786
787 /* signal parent */
788 dummy = 0;
789 write( sync_pipe[1], &dummy, 1 );
790 close( sync_pipe[1] );
791 break;
792
793 case -1:
794 fatal_perror( "fork" );
795 break;
796
797 default: /* parent */
798 close( sync_pipe[1] );
799
800 /* wait for child to signal us and then exit */
801 if (read( sync_pipe[0], &dummy, 1 ) == 1) _exit(0);
802
803 /* child terminated, propagate exit status */
804 wait4( pid, &status, 0, NULL );
805 if (WIFEXITED(status)) _exit( WEXITSTATUS(status) );
806 _exit(1);
807 }
808 }
809 else /* remain in the foreground */
810 {
811 acquire_lock();
812 }
acquire_lock() is used to setup the master socket, Question is when run in background,why fork() and let the child process do the work,while the parent just wait and exit()? And why not when run in foreground ?