Changeset 2104:4140ab350dda in roaraudio


Ignore:
Timestamp:
07/21/09 15:55:20 (15 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

added pidfile support

File:
1 edited

Legend:

Unmodified
Added
Removed
  • roard/roard.c

    r2087 r2104  
    2929#endif 
    3030 
     31#if defined(ROAR_HAVE_IO_POSIX) && defined(ROAR_HAVE_FS_POSIX) 
     32#define SUPPORT_PIDFILE 
     33char * pidfile = NULL; 
     34#endif 
     35 
    3136#ifdef ROAR_HAVE_MAIN_ARGS 
    3237void usage (void) { 
     
    4550        " --sysclocksync        - calculate exact sample rate using the system clock\n" 
    4651        " --location  LOC       - Set lion readable location of server\n" 
     52#ifdef SUPPORT_PIDFILE 
     53        " --pidfile PIDFILE     - Write a pidfile at PIDFILE\n" 
     54#endif 
    4755       ); 
    4856 
     
    533541 char decnethost[80]; 
    534542#endif 
     543#ifdef SUPPORT_PIDFILE 
     544 struct roar_vio_calls pidfile_vio; 
     545#endif 
    535546 
    536547 g_standby       =  0; 
     
    653664  } else if ( strcmp(k, "--location") == 0 ) { 
    654665   g_config->location = argv[++i]; 
     666  } else if ( strcmp(k, "--pidfile") == 0 ) { 
     667#ifdef SUPPORT_PIDFILE 
     668   pidfile = argv[++i]; 
     669#else 
     670   ROAR_ERR("--pidfile not supported"); 
     671   i++; 
     672#endif 
    655673 
    656674  } else if ( strcmp(k, "--list-cf") == 0 ) { 
     
    10191037#endif 
    10201038 
     1039#ifdef SUPPORT_PIDFILE 
     1040 if ( roar_vio_open_file(&pidfile_vio, pidfile, O_WRONLY|O_CREAT, 0644) == -1 ) { 
     1041  ROAR_ERR("Can not write pidfile: %s", pidfile); 
     1042 } else { 
     1043  roar_vio_printf(&pidfile_vio, "%i\n", getpid()); 
     1044  roar_vio_close(&pidfile_vio); 
     1045 } 
     1046#endif 
     1047 
    10211048#ifdef ROAR_HAVE_CHROOT 
    10221049 if (chrootdir) { 
     
    10971124 midi_free(); 
    10981125 light_free(); 
     1126 
     1127#ifdef SUPPORT_PIDFILE 
     1128 if ( pidfile != NULL ) 
     1129  unlink(pidfile); 
     1130#endif 
    10991131} 
    11001132 
Note: See TracChangeset for help on using the changeset viewer.