Changeset 2111:db1452dc98ea in roaraudio


Ignore:
Timestamp:
07/22/09 15:27:46 (15 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

added support to kill by pidfile at least for --stop

File:
1 edited

Legend:

Unmodified
Added
Removed
  • roard/roard.c

    r2109 r2111  
    140140int restart_server (char * server, int terminate) { 
    141141 struct roar_connection con; 
     142#ifdef ROAR_HAVE_KILL 
     143 char buf[80]; 
     144 ssize_t l; 
     145 struct roar_vio_calls fh; 
     146 pid_t pid; 
     147 int ok; 
     148 
     149 if ( pidfile != NULL ) { 
     150  if ( roar_vio_open_file(&fh, pidfile, O_RDONLY, 0644) == -1 ) { 
     151   ROAR_WARN("restart_server(*): Can not read pidfile: %s", pidfile); 
     152  } else { 
     153   l = roar_vio_read(&fh, buf, 80); 
     154   roar_vio_close(&fh); 
     155   if ( l > 0 ) { 
     156    buf[l-1] = 0; 
     157    buf[79]  = 0; 
     158    pid = atoi(buf); 
     159    if ( terminate ) { 
     160     ok = -1; 
     161    } else { 
     162     ok = kill(pid, SIGINT); 
     163    } 
     164    if ( ok == 0 ) { 
     165     return 0; 
     166    } else { 
     167     ROAR_WARN("restart_server(*): Can not kill roard by pidfile"); 
     168    } 
     169   } else { 
     170    ROAR_WARN("restart_server(*): Can not find a PID in the pidfile"); 
     171   } 
     172  } 
     173 } 
     174#endif 
    142175 
    143176 if ( roar_connect(&con, server) == -1 ) { 
     
    649682  } else if ( strcmp(k, "--stop") == 0 ) { 
    650683#ifdef ROAR_SUPPORT_LISTEN 
    651    if ( restart_server(server, 1) == -1 ) { 
     684   if ( restart_server(server, 0) == -1 ) { 
    652685    ROAR_WARN("Can not stop old server (not running at %s?)", server); 
    653686    return 1; 
Note: See TracChangeset for help on using the changeset viewer.