Changeset 449:e23bae640634 in roaraudio


Ignore:
Timestamp:
08/12/08 02:13:13 (16 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

added proc_name() to roarctl so it shows a proc name in addtion to the PID

File:
1 edited

Legend:

Unmodified
Added
Removed
  • roarclients/roarctl.c

    r445 r449  
    6363} 
    6464 
     65const char * proc_name (pid_t pid) { 
     66 static char ret[80] = "?"; 
     67#ifdef __linux__ 
     68 char file[80], buf[80], *r; 
     69 int  i; 
     70 
     71 snprintf(file, 79, "/proc/%i/exe", pid); 
     72 file[79] = 0; 
     73 
     74 ret[0] = '?'; 
     75 ret[1] = 0; 
     76 
     77 if ( (i = readlink(file, buf, 79)) != -1 ) { 
     78  buf[i] = 0; 
     79  if ( (r = strrchr(buf, '/')) != NULL ) { 
     80   r++; 
     81   if ( *r != 0 ) 
     82    strcpy(ret, r); 
     83  } 
     84 } 
     85#endif 
     86 
     87 return ret; 
     88} 
     89 
    6590void list_clients (struct roar_connection * con) { 
    6691 int i; 
     
    84109  } 
    85110  printf("Player name           : %s\n", c.name); 
    86   printf("Player PID            : %i\n", c.pid); 
     111  printf("Player PID            : %i(%s)\n", c.pid, proc_name(c.pid)); 
    87112  if ( c.uid != -1 ) { 
    88113   pwd = getpwuid(c.uid); 
Note: See TracChangeset for help on using the changeset viewer.