Ignore:
Timestamp:
30/05/06 17:22:44 (14 years ago)
Author:
spascoe
Message:

bbftpd.run() now returns to python in the calling process. This allows
the original process to monitor the daemon.

Location:
TI05-delivery/trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • TI05-delivery/trunk/src/Makefile

    r1064 r1065  
    2626        make -C $(BBFTPD) install 
    2727 
    28 clean: 
     28clean: clean_server clean_client 
     29 
     30clean_server: 
    2931        -rm $(BBFTPD)/*.o $(BBFTPD)/bbftpd 
     32 
     33clean_client: 
    3034        -rm $(BBFTPC)/*.o $(BBFTPC)/bbftp 
  • TI05-delivery/trunk/src/bbftp-server-3.2.0/bbftpd/bbftpd.c

    r1064 r1065  
    805805        ** Run as a daemon  
    806806        */ 
     807#ifdef NDG_PYTHON_EMBED 
     808      if ((fatherpid = do_daemon(argc, argv, envp)) > 0) return fatherpid; 
     809#else 
    807810        do_daemon(argc, argv, envp); 
     811#endif 
    808812        /* 
    809813        ** Check for debug 
     
    14131417  int argc, i; 
    14141418  char **argv, **arg_p; 
     1419  int pid; 
    14151420 
    14161421  /* 
     
    14321437  } 
    14331438 
    1434   bbftpd_main(argc, argv, environ); 
    1435  
    1436   // I'm not sure we ever get here. 
     1439  pid = bbftpd_main(argc, argv, environ); 
     1440 
    14371441  free(argv); 
    1438   Py_RETURN_NONE; 
     1442  return Py_BuildValue("i", pid); 
    14391443} 
    14401444 
    14411445static PyMethodDef BbftpdMethods[] = { 
    1442   {"run", bbftpd_run, METH_VARARGS, "Execute the bbftpd server"}, 
     1446  {"run", bbftpd_run, METH_VARARGS, "Execute the bbftpd server.  Returns the PID of the server process"}, 
    14431447  {NULL, NULL, 0, NULL} 
    14441448}; 
  • TI05-delivery/trunk/src/bbftp-server-3.2.0/bbftpd/bbftpd_daemon.c

    r773 r1065  
    8787extern int outcontrolsock ; 
    8888 
     89#ifdef NDG_PYTHON_EMBED 
     90int do_daemon(int argc, char **argv, char **envp) 
     91#else 
    8992void do_daemon(int argc,char **argv,char **envp) 
     93#endif 
    9094{ 
    9195 
     
    133137        exit(1); 
    134138    } 
     139#ifdef NDG_PYTHON_EMBED 
     140    /* Return the daemon's PID */ 
     141    if (retcode > 0) return retcode; 
     142#else 
    135143    /* No need for the parent any more */ 
    136144    if (retcode > 0) _exit(0); 
    137  
     145#endif 
    138146    prpg = 0 ; 
    139147    prpg = setsid () ;     /* disassoiciate from control terminal */ 
     
    214222                incontrolsock = msgsock ; 
    215223                outcontrolsock = msgsock ; 
    216                    return; 
     224#ifdef NDG_PYTHON_EMBED 
     225                return 0; 
     226#else 
     227                return; 
     228#endif 
     229            
    217230                } 
    218231 
Note: See TracChangeset for help on using the changeset viewer.