Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7837751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T14:49:58+00:00 2026-06-02T14:49:58+00:00

When the Wine server launches, it creates a Unix socket through open_master_socket(),all Wine processes

  • 0

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 ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T14:49:58+00:00Added an answer on June 2, 2026 at 2:49 pm

    Yes,Daemon!
    Thanks to ninjalj,This is a general method to implement a background running daemon,and let the forked child(the daemon) do the daemon thing.
    And the parent to use _exit() rather than exit() is to avoid removing temporary file unexpectedly.
    For more about daemon,see
    how to make a process daemon and
    http://software.clapper.org/daemonize/

    And geekosaur explains well why we need wait the child before _exit().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to launch MS Office through WINE using a Perl script hosted
In a bash script, I'm using wine to call a DOS program that requires
I am porting an application from foxpro to C#.Net. This is a wine shop
I recently installed Warcraft3:TFT on my Mac using Wine because the Mac version doen't
I'm running the windows version of Tribler using wine in Ubuntu 10.10. Some times
I am using ubuntu 10.04 and i want to use dreamweaver using wine, when
I have tested all my systems developed in Delphi (in Windows XP) on Wine
Is it possible to use native Win API functions in Mono through Wine? Are
The following shell script takes a list of arguments, turns Unix paths into WINE/Windows
I have dynamically generated a list of wine types from the database using AJAx

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.