aboutsummaryrefslogtreecommitdiff
path: root/libps/procstat.c
Commit message (Collapse)AuthorAgeFilesLines
* libps: Fix allocating args/envSamuel Thibault2023-05-231-6/+4
| | | | proc_getprocargs and proc_getprocenv read their size value
* libps: Port to x86_64Sergey Bugaev2023-05-101-6/+12
| | | | Message-Id: <20230508213136.608575-12-bugaevc@gmail.com>
* Modernize code by removing use of old style definitions.Flavio Cruz2023-04-031-3/+2
| | | | | Also add -Werror=old-style-definition to enforce new code. Message-Id: <ZBZ+8xf7GHy2RT/h@jupiter.tail36e24.ts.net>
* libps: Fix memory leakRichard Braun2022-11-051-0/+1
| | | | Message-Id: <20221105141505.4684-1-rbraun@sceen.net>
* Implement /proc/<pid>/exeSamuel Thibault2018-01-081-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | by adding proc_set/get_exe to the proc server, making exec call proc_set_exe, and libps call proc_get_exe. procfs can then just retrieve the information to make the "exe" symlink. * hurd/process.defs (proc_set_exe, proc_get_exe): New RPCs. * hurd/process_request.defs: Likewise. * hurd/process_reply.defs: Add skips for proc_set_exe and proc_get_exe RPCs. * proc/proc.h (struct proc): Add `exe' field. * proc/info.c (S_proc_set_exe, S_proc_get_exe): New functions. * proc/mgt.c (process_has_exited): Free p->exe. (S_proc_child): Duplicate parent `exe' into child's `exe'. * exec/exec.c (do_exec): Call proc_set_exe when a filename is available. * libps/ps.h (struct proc_stat): Add `exe_vm_alloced', `exe', and `exe_len' field. (PSTAT_EXE): New macro. (PSTAT_USER_BASE): Change value to make room. (proc_stat_exe, proc_stat_exe_len): New macros. * libps/procstat.c (proc_stat_set_flags): Handle PSTAT_EXE case by calling proc_get_exe. * libps/spec.c (ps_get_exe): New function. (ps_exe_getter): New structure. (ps_fmt_spec): Add "Exe" specification. * procfs/process.c (process_file_symlink_make_node, process_file_gc_exe): New functions. (procfs_dir_entry): Add "exe" entry. * startup/startup.c (launch_core_servers): Set exe paths for startup, auth, proc, and fs servers. (frob_kernel_process): Set exe path for kernel task. (S_startup_essential_task): Set exe path for exec server.
* Replace bcopy with memcpy or memmove as appropriate.Justus Winter2017-08-051-5/+5
| | | | | | | | | | | * boot/boot.c: Replace bcopy with memcpy or memmove as appropriate. * exec/hashexec.c: Likewise. * libps/proclist.c: Likewise, but also fix the amount of data copied. * libps/procstat.c: Likewise. * libps/spec.c: Likewise. * libshouldbeinlibc/cacheq.c: Likewise. * libshouldbeinlibc/idvec.c: Likewise. * libshouldbeinlibc/timefmt.c: Likewise.
* Use our own variant of 'assert' and 'assert_perror'.Justus Winter2017-08-051-1/+1
| | | | | Our variants print stack traces on failures. This will make locating errors much easier.
* Replace `bzero' with `memset'Justus Winter2014-12-101-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For reference, this patch was created using the following semantic patch, and then manually applying the change in all functions containing nested functions, as those are not supported by Coccinelle. @@ expression A, B; @@ - bzero (A, B) + memset (A, 0, B) * auth/auth.c: Replace `bzero' with `memset'. * boot/boot.c: Likewise. * defpager/defpager.c: Likewise. * exec/exec.c: Likewise. Also, drop `safe_bzero' and just use `hurd_safe_memset' directly. * ext2fs/ext2fs.c: Likewise. * ext2fs/getblk.c: Likewise. * ext2fs/pager.c: Likewise. * fatfs/pager.c: Likewise. * ftpfs/dir.c: Likewise. * ftpfs/netfs.c: Likewise. * isofs/inode.c: Likewise. * isofs/pager.c: Likewise. * libdiskfs/file-getfh.c: Likewise. * libdiskfs/file-statfs.c: Likewise. * libfshelp/fetch-root.c: Likewise. * libfshelp/start-translator.c: Likewise. * libftpconn/create.c: Likewise. * libftpconn/open.c: Likewise. * libftpconn/unix.c: Likewise. * libpipe/pipe.c: Likewise. * libps/procstat.c: Likewise. * libps/spec.c: Likewise. * libshouldbeinlibc/cacheq.c: Likewise. * libshouldbeinlibc/idvec.c: Likewise. * libshouldbeinlibc/ugids.c: Likewise. * libstore/argp.c: Likewise. * libstore/enc.c: Likewise. * libstore/kids.c: Likewise. * libthreads/alpha/thread.c: Likewise. * libtreefs/fsys.c: Likewise. * libtrivfs/file-statfs.c: Likewise. * mach-defpager/default_pager.c: Likewise. * pfinet/glue-include/asm/uaccess.h: Likewise. * pfinet/io-ops.c: Likewise. * pfinet/options.c: Likewise. * pfinet/socket.c: Likewise. * pfinet/timer-emul.c: Likewise. * pflocal/io.c: Likewise. * startup/startup.c: Likewise. * storeio/storeio.c: Likewise. * sutils/fstab.c: Likewise. * usermux/usermux.c: Likewise. * utils/fakeauth.c: Likewise. * utils/frobauth.c: Likewise. * utils/login.c: Likewise. * utils/x.c: Likewise.
* Fix proc_getprocinfo callsSamuel Thibault2014-11-021-2/+2
| | | | | | | | | | | The deallocation also needs to be fixed. Also, fetch_procinfo already took care of the conversion. * exec/elfcore.c (dump_core): Fix procinfoCnt taken from proc_getprocinfo. * utils/login.c (check_owned): Likewise. * libps/procstat.c (merge_procinfo): Remove conversion between bytes and int, already handled by fetch_procinfo.
* Fix proc_getprocinfo callsSamuel Thibault2014-11-021-2/+2
| | | | | | | | | The procinfoCnt argument is the number of elements of the procinfo_t array, not its size in bytes. * exec/elfcore.c (dump_core): Fix procinfoCnt given to proc_getprocinfo. * libps/procstat.c (merge_procinfo): Likewise. * utils/login.c (check_owned): Likewise.
* libps: fix task/thread times fetchingRichard Braun2014-01-161-8/+16
| | | | | | | | | | | | | | | | | | | | | Introduce PSTAT_TIMES to force the retrieval of both PSTAT_TASK_BASIC and PSTAT_THREAD_BASIC. Task basic info contain the user and system times of terminated threads which the code wrongly assumes is always present along with process info. * libps/procstat.c (add_preconditions): Set both PSTAT_TASK_BASIC and PSTAT_THREAD_BASIC as preconditions for PSTAT_TIMES. (summarize_thread_basic_info): Add terminated threads times only if task basic info are available. (set_procinfo_flags): Provide summarize_thread_basic_info with flags of available info. (proc_stat_set_flags): Set PSTAT_TIMES as available if it was needed and any of PSTAT_TASK_BASIC or PSTAT_THREAD_BASIC could be fetched. * libps/ps.h (PSTAT_TIMES): New macro. * libps/spec.c (ps_get_usr_time): Indicate the getter needs PSTAT_TIMES instead of PSTAT_THREAD_BASIC. (ps_sys_time_getter): Likewise. (ps_tot_time_getter): Likewise.
* libps: fix process user and system timesRichard Braun2013-12-301-0/+7
| | | | | Include the run time of terminated threads in the user and system times of processes.
* Update nasty/nice priority limitSamuel Thibault2013-03-111-2/+2
| | | | | * libps/procstat.c (thread_state): Update nasty/nice limit to 25 instead of 12.
* Add TASK_EVENTS_INFO support to libpsDavid Höppner2013-01-131-0/+6
| | | | | | * libps/procstat.c (merge_procinfo): Also copy taskevents. * libps/procstat.c (set_procinfo_flags): Set pointer to task_events_info. * tasks: Remove TASK_EVENTS_INFO item.
* fix common misspellingsJonathan Neuschäfer2011-08-201-3/+3
| | | | | | * Fix spelling with codespell[1] and manually review it. [1] http://git.profusion.mobi/cgit.cgi/lucas/codespell/
* Obtain number of ports in proc and libpsantrik2010-09-181-0/+4
| | | | | | | | | | | | | | | | | | | Add (and implement) a proc RPC to obtain the number of Mach ports used by the target task. Add infrastructure in libps to read this information. * hurd/process.defs (proc_getnports): New RPC. * hurd/process_request.defs (proc_getnports_request): New RPC. * libps/procstat.c (proc_stat_set_flags): Call proc_getnports RPC if needed. * libps/ps.h (proc_stat): New `num_ports' field. (PSTAT_NUM_PORTS): New macro. (proc_stat_num_ports): New macro. * libps/spec.c (ps_get_num_ports): New function. (ps_num_ports_getter): New variable. (specs): New entry for `ps_num_ports_getter'. * proc/info.c (S_proc_getnports): New function.
* libps (proc_stat_set_flags): Fix pointer signedness warningJeremie Koenig2010-08-261-1/+1
| | | | | * libps/procstat.c (proc_stat_set_flags): Cast &ps->umask into (int*) before calling ps_msg_get_init_int.
* Merge branch 'master' of git.savannah.gnu.org:/srv/git/hurd/hurdSamuel Thibault2010-08-261-0/+2
|\
| * libps (_proc_stat_free): Fix memory leakJeremie Koenig2010-08-261-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The thread_waits field was never freed; this change adds the code to do so if the corresponding flag is set. Users are also warned of the consequences, namely, that they should not free process proc_stats before all their associated thread ones are gone, since the latter may reference the former's thread_waits field. However, with the normal interface (ie. ps_context_free), all proc_stats are freed at once, so this is not an issue. * libps/procstat.c (_proc_stat_free): Free ps->thread_waits if PSTAT_THREAD_WAITS flag is set. * libps/ps.h (_proc_stat_free): Document that thread proc_stats must be freed before process proc_stat can be.
* | libps (fetch_procinfo): Fix non-set flag PSTAT_TASK_EVENTSJeremie Koenig2010-08-261-22/+17
|/ | | | | | | | | | | | | | | The fetch_procinfo function failed to set the PSTAT_TASK_EVENTS when those has been retreived. It should be noted that GNU Mach does not support the TASK_EVENTS_INFO flavor, so this is of minor importance. The new code also checks that all the requested proc server flags related to a given proc_stat flags have been returned before setting the proc_stat flag in question. * libps/procstat.c (fetch_procinfo): Add map array containing `ps_flags_t' and `procinfo' flags. Use it in a loop to check for flags in `need' and `have' and set them in `pi_flags'. Likewise to check for flags in `pi_flags' and set them in `have'.
* libps: Fix deadly typoJeremie Koenig2010-08-261-1/+1
| | | | | | | | | PSTAT_PROCINFO is a set of flags, some of which can be obtained in alternative ways. In this case, _proc_stat_free will try to deallocate an uninitialised field. PSTAT_PROC_INFO is the flag we want. * libps/procstat.c (_proc_stat_free): Use PSTAT_PROC_INFO instead of PSTAT_PROCINFO.
* 2002-06-05 Roland McGrath <roland@frob.com>Roland McGrath2002-06-051-19/+7
| | | | | | | | * procstat.c (fetch_procinfo): Use PI_FETCH_TASKEVENTS. (add_preconditions): PSTAT_TASK_EVENTS no longer needs PSTAT_TASK. (PSTAT_PROCINFO_TASK): Add PSTAT_TASK_EVENTS to the mask. (PSTAT_PROCINFO_MERGE): Here too. (proc_stat_set_flags): Don't use task_info for PSTAT_TASK_EVENTS.
* 2002-05-07 Roland McGrath <roland@frob.com>Roland McGrath2002-05-081-1/+1
| | | | | | | | | * host.c (ps_host_basic_info): int -> size_t (ps_host_basic_info, ps_host_load_info): Likewise. * ps.h: Update decls. (struct proc_stat): unsigned -> size_t for task_events_info_size, args_len, env_len. * procstat.c (summarize_thread_waits): Fix argument type.
* 1999-07-03 Thomas Bushnell, BSG <tb@mit.edu>Thomas Bushnell1999-07-031-4/+2
| | | | | * common.h (VMFREE): Use munmap instead of vm_deallocate. * procstat.c (merge_procinfo): Likewise.
* 1999-06-02 Roland McGrath <roland@baalperazim.frob.com>Roland McGrath1999-06-021-1/+22
| | | | | | | | | | | * ps.h (PSTAT_ENV): New macro. (struct proc_stat): New members `env', `env_len', `env_vm_alloced'. (proc_stat_env, proc_stat_env_len): New accessor macros. (PSTAT_USER_BASE): Increase value to leave more room for additions. * procstat.c (proc_stat_set_flags): Handle environment. (_proc_stat_free): Likewise. * spec.c (ps_get_env, ps_env_getter): New function and constant. (specs): New spec "Env" using ps_env_getter and ps_emit_args.
* Add braces to silence gcc warnings.Roland McGrath1998-10-201-57/+65
|
* fix typoThomas Bushnell1997-05-231-1/+1
|
* Fri May 23 13:13:18 1997 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu>Thomas Bushnell1997-05-231-5/+10
| | | | | | | | * procstat.c (summarize_thread_basic_info): Don't include the kernel's idle threads in the summation. (summarize_thread_sched_info): Likewise. (summarize_thread_states): Likewise. (summarize_thread_waits): Likewise.
* (proc_stat_set_flags):Miles Bader1996-11-161-3/+6
| | | | | Allow the user fetch hook to turn on non-user bits, even if they've already failed in the standard code.
* (proc_stat_set_flags):Miles Bader1996-10-081-8/+3
| | | | | Get rid of INAPP macro. Fix preconditions of PSTAT_SUSPEND_COUNT.
* (proc_stat_thread_create):Miles Bader1996-10-081-38/+75
| | | | | | | | | | | | | | | | | | | Initialize FAILED and INAPP fields. (PSTAT_PROCINFO): Redefined. (set_procinfo_flags): Set bits in PS->inapp as appropriate. (count_threads): Use PSTAT_PROCINFO_TASK_THREAD_DEP. (PSTAT_PROCINFO_TASK_THREAD_DEP): Renamed from PSTAT_PROCINFO_THREAD. (PSTAT_PROCINFO_THREAD, PSTAT_PROCINFO_TASK): New macro. (proc_stat_set_flags): Add NEED & INAPP macros, and use them to set the inapp field as well as the failed field. (_proc_stat_create): Initialize INAPP field.
* (set_procinfo_flags): Pass HAVE to count_threads.Miles Bader1996-08-021-10/+18
| | | | | (count_threads): Take new argument HAVE, and use different thread counting method depending on whether we have thread detail info.
* (set_procinfo_flags): Don't use fake "*" wait value if there's no msgport.Miles Bader1996-07-111-1/+2
|
* (proc_stat_set_flags):Miles Bader1996-07-021-1/+1
| | | | Pass PS->task_events_info to task_info, not its address.
* (merge_procinfo):Miles Bader1996-06-031-60/+72
| | | | | | | | | | | | | | | Take a struct proc_stat as an arg, not all the individual fields. Correctly set old_pi_hdr. Correctly calculate REALLY_NEED. (set_procinfo_flags): Use new calling merge_procinfo calling convention. (proc_stat_set_flags): Try mallocing a buffer for PS->args. Move second call to set_procinfo_flags after msgport suppress test. Add TEST_MSGPORT_FLAGS variable, & use it. Be more picky about when we call set_procinfo_flags. (_proc_stat_free): Use explicit VM_ALLOCED flag for MFREEMEM.
* (set_procinfo_flags): New function.Miles Bader1996-06-021-199/+246
| | | | | | | | | | | (proc_stat_set_flags): Use it, to get msgport validity testing right. (merge_procinfo): Take and return HAVE instead of using a reference parameter. Do mem allocation more efficiently and correctly. (fetch_procinfo): Do conversion for PI_SIZE from/to units of sizeof (int), so no one else has to deal with it. (PROCINFO_MALLOC_SIZE, WAITS_MALLOC_SIZE): New macros. (MFREEMEM): New macro combining MFREEM & MFREEVM. (MFREEM, MFREEVM): Macros deleted.
* (proc_stat_set_flags): After fetching number of threads to guess whether weMiles Bader1996-05-311-14/+38
| | | | | | | | need wait info, put it in PS->num_threads. (merge_procinfo): Avoid vm_allocing a procinfo buffer each time if we can help it. Correctly reflect newly fetched info. (PSTAT_PROCINFO_MERGE, PSTAT_PROCINFO_REFETCH): New macros.
* (MP_MGET): Only disable msgport on timeout.Miles Bader1996-05-291-15/+12
| | | | | | | (get_thread_wait): Decrement N in loop. (get_thread_wait): Use strnlen instead of memchr. (PSTAT_PROCINFO): Typo: PSTAT_THREAD_WAIT --> PSTAT_THREAD_WAITS. (PSTAT_USES_MSGPORT): Add PSTAT_THREAD_WAIT.
* (merge_procinfo): Don't die if WAITS == 0.Miles Bader1996-05-291-16/+32
| | | | | | | (summarize_thread_waits): Correctly advance NEXT_WAIT. Skip threads marked `itimer'. (proc_stat_set_flags): Consider processes with less than 4 threads to be candidates for a meaningful process wait status.
* (merge_procinfo): And update *HAVE with PSTAT_PROC_INFO fromMichael I. Bushnell1996-05-241-1/+2
| | | | REALLY_HAVE here.
* (fetch_procinfo): Always turn on PSTAT_PROC_INFO if proc_getprocinfoMichael I. Bushnell1996-05-241-0/+1
| | | | returns successfully.
* (PSTAT_PROCINFO, PSTAT_PROCINFO_THREAD): Add PSTAT_THREAD_WAITS.Miles Bader1996-05-131-27/+69
| | | | | | | | | (proc_stat_set_flags): Be more careful about when we fetch thread_wait information, and synthesize a process-summary thread_wait value for lots of threads. (summarize_thread_waits): Only give a real summary if there's but a single user thread. (fetch_procinfo): Use PSTAT_THREAD_WAITS instead of PSTAT_THREAD_WAIT.
* (merge_procinfo, fetch_procinfo): Change HAVE to be an input/output parameter.Miles Bader1996-05-121-30/+40
| | | | | (proc_stat_set_flags): Change accordingly. (get_thread_wait): Correctly advance WAIT.
* (get_thread_wait): Correctly advance WAIT.Miles Bader1996-05-121-1/+5
|
* Frob comment.Miles Bader1996-05-121-1/+3
|
* (fetch_procinfo): Pass a reference to PI_FLAGS in call toMichael I. Bushnell1996-05-091-1/+1
| | | | fetch_procinfo.
* (add_preconditions, proc_stat_set_flags): Remove references to exec_flags.Miles Bader1996-05-071-6/+1
|
* (proc_stat_set_flags): Use new `ps_' prefix for msg rpcs.Miles Bader1996-03-271-7/+11
| | | | Include "ps_msg.h".
* Get rid of mega typedefs, and just use structure pointers like other hurdMiles Bader1996-03-261-54/+54
| | | | libraries. Other misc cleanups.
* (fetch_procinfo, merge_procinfo): Return wait strings.Miles Bader1996-02-131-33/+74
| | | | | | | (summarize_thread_waits): Return both wait and rpc info. (get_thread_wait): New function. (proc_stat_set_flags): Support finding wait info. Change occurances of PSTAT_THREAD_RPC to PSTAT_THREAD_WAIT.