Changeset 30598 in vbox for trunk/src/VBox/GuestHost/OpenGL/util
- Timestamp:
- Jul 5, 2010 10:23:45 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/GuestHost/OpenGL/util/process.c
r15532 r30598 146 146 if (!tmp) 147 147 return; 148 149 148 /* pipe output of ps to temp file */ 149 #ifndef SunOS 150 150 sprintf(command, "ps > %s", tmp); 151 #else 152 sprintf(command, "ps -e -o 'pid tty time comm'> %s", tmp); 153 #endif 151 154 system(command); 152 155 … … 154 157 f = fopen(tmp, "r"); 155 158 if (f) { 156 char buffer[1000], cmd[1000] ;159 char buffer[1000], cmd[1000], *psz, *pname; 157 160 while (!feof(f)) { 158 161 int id; … … 160 163 sscanf(buffer, "%d %*s %*s %999s", &id, cmd); 161 164 if (id == pid) { 162 crStrncpy(name, cmd, maxLen); 165 for (pname=psz=&cmd[0]; *psz!=0; psz++) 166 { 167 switch (*psz) 168 { 169 case '/': 170 pname = psz+1; 171 break; 172 } 173 } 174 crStrncpy(name, pname, maxLen); 163 175 break; 164 176 }
Note:
See TracChangeset
for help on using the changeset viewer.