183 |
|
if(ptr !=NULL) *ptr='\0'; |
184 |
|
|
185 |
|
if (sg_update_string(&proc_state_ptr->process_name, |
186 |
< |
&ps_name[1]) == NULL) { |
186 |
> |
&ps_name[1]) < 0) { |
187 |
|
return NULL; |
188 |
|
} |
189 |
|
|
204 |
|
#define READ_BLOCK_SIZE 128 |
205 |
|
len = 0; |
206 |
|
do { |
207 |
< |
if (VECTOR_RESIZE(psargs, len + READ_BLOCK_SIZE + 1) < 0) { |
207 |
> |
if (VECTOR_RESIZE(psargs, len + READ_BLOCK_SIZE) < 0) { |
208 |
|
return NULL; |
209 |
|
} |
210 |
|
rc = read(fn, psargs + len, READ_BLOCK_SIZE); |
225 |
|
if (*ptr == '\0') *ptr = ' '; |
226 |
|
ptr++; |
227 |
|
} |
228 |
– |
/* for safety's sake */ |
229 |
– |
psargs[len] = '\0'; |
228 |
|
|
229 |
< |
if (sg_update_string(&proc_state_ptr->proctitle, psargs) == NULL) { |
229 |
> |
if (len == 0) { |
230 |
> |
/* We want psargs to be NULL. */ |
231 |
> |
if (VECTOR_RESIZE(psargs, 0) < 0) { |
232 |
> |
return NULL; |
233 |
> |
} |
234 |
> |
} else { |
235 |
> |
/* Not empty, so append a \0. */ |
236 |
> |
if (VECTOR_RESIZE(psargs, len + 1) < 0) { |
237 |
> |
return NULL; |
238 |
> |
} |
239 |
> |
psargs[len] = '\0'; |
240 |
> |
} |
241 |
> |
|
242 |
> |
if (sg_update_string(&proc_state_ptr->proctitle, psargs) < 0) { |
243 |
|
return NULL; |
244 |
|
} |
245 |
|
#endif |
289 |
|
#else |
290 |
|
name = kp_stats[i].kp_proc.p_comm; |
291 |
|
#endif |
292 |
< |
if (sg_update_string(&proc_state_ptr->process_name, name) == NULL) { |
292 |
> |
if (sg_update_string(&proc_state_ptr->process_name, name) < 0) { |
293 |
|
return NULL; |
294 |
|
} |
295 |
|
|