1 |
/* Process information queries |
/* Process information queries |
2 |
Copyright (C) 1992,93,94,95,96,99,2000,01 Free Software Foundation, Inc. |
Copyright (C) 1992,93,94,95,96,99,2000,01,02 Free Software Foundation, Inc. |
3 |
|
|
4 |
This file is part of the GNU Hurd. |
This file is part of the GNU Hurd. |
5 |
|
|
165 |
|
|
166 |
vm_address_t readaddr; |
vm_address_t readaddr; |
167 |
vm_address_t data; |
vm_address_t data; |
168 |
u_int readlen; |
size_t readlen; |
169 |
error_t err; |
error_t err; |
170 |
char *c; |
char *c; |
171 |
|
|
261 |
get_string_array (task_t t, |
get_string_array (task_t t, |
262 |
vm_address_t loc, |
vm_address_t loc, |
263 |
vm_address_t *buf, |
vm_address_t *buf, |
264 |
u_int *buflen) |
size_t *buflen) |
265 |
{ |
{ |
266 |
char *bp; |
char *bp; |
267 |
int *vector, *vp; |
int *vector, *vp; |
334 |
S_proc_getprocargs (struct proc *callerp, |
S_proc_getprocargs (struct proc *callerp, |
335 |
pid_t pid, |
pid_t pid, |
336 |
char **buf, |
char **buf, |
337 |
u_int *buflen) |
size_t *buflen) |
338 |
{ |
{ |
339 |
struct proc *p = pid_find (pid); |
struct proc *p = pid_find (pid); |
340 |
|
|
351 |
S_proc_getprocenv (struct proc *callerp, |
S_proc_getprocenv (struct proc *callerp, |
352 |
pid_t pid, |
pid_t pid, |
353 |
char **buf, |
char **buf, |
354 |
u_int *buflen) |
size_t *buflen) |
355 |
{ |
{ |
356 |
struct proc *p = pid_find (pid); |
struct proc *p = pid_find (pid); |
357 |
|
|
373 |
pid_t pid, |
pid_t pid, |
374 |
int *flags, |
int *flags, |
375 |
int **piarray, |
int **piarray, |
376 |
u_int *piarraylen, |
size_t *piarraylen, |
377 |
char **waits, mach_msg_type_number_t *waits_len) |
char **waits, mach_msg_type_number_t *waits_len) |
378 |
{ |
{ |
379 |
struct proc *p = pid_find (pid); |
struct proc *p = pid_find (pid); |
380 |
struct procinfo *pi; |
struct procinfo *pi; |
381 |
int nthreads; |
size_t nthreads; |
382 |
thread_t *thds; |
thread_t *thds; |
383 |
error_t err = 0; |
error_t err = 0; |
384 |
size_t structsize; |
size_t structsize; |
386 |
int pi_alloced = 0, waits_alloced = 0; |
int pi_alloced = 0, waits_alloced = 0; |
387 |
/* The amount of WAITS we've filled in so far. */ |
/* The amount of WAITS we've filled in so far. */ |
388 |
mach_msg_type_number_t waits_used = 0; |
mach_msg_type_number_t waits_used = 0; |
389 |
u_int tkcount, thcount; |
size_t tkcount, thcount; |
390 |
struct proc *tp; |
struct proc *tp; |
391 |
task_t task; /* P's task port. */ |
task_t task; /* P's task port. */ |
392 |
mach_port_t msgport; /* P's msgport, or MACH_PORT_NULL if none. */ |
mach_port_t msgport; /* P's msgport, or MACH_PORT_NULL if none. */ |
470 |
if (*flags & PI_FETCH_TASKINFO) |
if (*flags & PI_FETCH_TASKINFO) |
471 |
{ |
{ |
472 |
tkcount = TASK_BASIC_INFO_COUNT; |
tkcount = TASK_BASIC_INFO_COUNT; |
473 |
err = task_info (task, TASK_BASIC_INFO, (int *)&pi->taskinfo, &tkcount); |
err = task_info (task, TASK_BASIC_INFO, |
474 |
|
(task_info_t) &pi->taskinfo, &tkcount); |
475 |
if (err == MACH_SEND_INVALID_DEST) |
if (err == MACH_SEND_INVALID_DEST) |
476 |
err = ESRCH; |
err = ESRCH; |
477 |
|
#ifdef TASK_SCHED_TIMESHARE_INFO |
478 |
|
if (!err) |
479 |
|
{ |
480 |
|
tkcount = TASK_SCHED_TIMESHARE_INFO_COUNT; |
481 |
|
err = task_info (task, TASK_SCHED_TIMESHARE_INFO, |
482 |
|
(int *)&pi->timeshare_base_info, &tkcount); |
483 |
|
if (err == KERN_INVALID_POLICY) |
484 |
|
{ |
485 |
|
pi->timeshare_base_info.base_priority = -1; |
486 |
|
err = 0; |
487 |
|
} |
488 |
|
} |
489 |
|
#endif |
490 |
} |
} |
491 |
|
|
492 |
for (i = 0; i < nthreads; i++) |
for (i = 0; i < nthreads; i++) |
497 |
{ |
{ |
498 |
thcount = THREAD_BASIC_INFO_COUNT; |
thcount = THREAD_BASIC_INFO_COUNT; |
499 |
err = thread_info (thds[i], THREAD_BASIC_INFO, |
err = thread_info (thds[i], THREAD_BASIC_INFO, |
500 |
(int *)&pi->threadinfos[i].pis_bi, |
(thread_info_t) &pi->threadinfos[i].pis_bi, |
501 |
&thcount); |
&thcount); |
502 |
if (err == MACH_SEND_INVALID_DEST) |
if (err == MACH_SEND_INVALID_DEST) |
503 |
{ |
{ |
517 |
{ |
{ |
518 |
thcount = THREAD_SCHED_INFO_COUNT; |
thcount = THREAD_SCHED_INFO_COUNT; |
519 |
err = thread_info (thds[i], THREAD_SCHED_INFO, |
err = thread_info (thds[i], THREAD_SCHED_INFO, |
520 |
(int *)&pi->threadinfos[i].pis_si, |
(thread_info_t) &pi->threadinfos[i].pis_si, |
521 |
&thcount); |
&thcount); |
522 |
if (err == MACH_SEND_INVALID_DEST) |
if (err == MACH_SEND_INVALID_DEST) |
523 |
{ |
{ |
643 |
S_proc_getloginpids (struct proc *callerp, |
S_proc_getloginpids (struct proc *callerp, |
644 |
pid_t id, |
pid_t id, |
645 |
pid_t **pids, |
pid_t **pids, |
646 |
u_int *npids) |
size_t *npids) |
647 |
{ |
{ |
648 |
error_t err = 0; |
error_t err = 0; |
649 |
struct proc *l = pid_find (id); |
struct proc *l = pid_find (id); |