/[LeafOK_CVS]/lbbs/src/fork.c
ViewVC logotype

Diff of /lbbs/src/fork.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.1 by sysadm, Mon Oct 11 11:15:33 2004 UTC Revision 1.7 by sysadm, Fri Oct 22 15:20:32 2004 UTC
# Line 1  Line 1 
1  /***************************************************************************  /***************************************************************************
2                            fork.c  -  description                            fork.c  -  description
3                               -------------------                               -------------------
4      begin                : Mon Oct 11 2004      begin                : Mon Oct 18 2004
5      copyright            : (C) 2004 by Leaf      copyright            : (C) 2004 by Leaflet
6      email                : leaflet@leafok.com      email                : leaflet@leafok.com
7   ***************************************************************************/   ***************************************************************************/
8    
# Line 15  Line 15 
15   *                                                                         *   *                                                                         *
16   ***************************************************************************/   ***************************************************************************/
17    
18   #include "common.h"  #include "common.h"
19    #include "io.h"
20    #include <string.h>
21    
22    int
23    fork_server()
24    {
25      int pid;
26          
27      if (pid = fork ())
28        return 0;
29      else if (pid < 0)
30        return -1;
31    
32      log_std ("Child process start\n");
33      
34      if (close(socket_server) == -1)
35        {
36          log_error("Close server socket failed\n");
37          return -2;
38        }
39    
40      //Redirect Output
41      close(1);
42      if (dup2 (socket_client, 1) == -1)
43        {
44          log_error("Redirect stdout to client socket failed\n");
45          return -3;
46        }
47    
48      bbs_main();
49      
50      if (close(socket_client) == -1)
51        {
52          log_error("Close client socket failed\n");
53        }
54    
55      log_std ("Child process exit\n");
56    
57      log_end();
58    
59      //Exit child process normally
60      exit(0);
61    
62      return 0;
63    }


Legend:
Removed lines/characters  
Changed lines/characters
  Added lines/characters

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1