summaryrefslogtreecommitdiffstats
path: root/bin/ps/ps.c
Commit message (Collapse)AuthorAgeFilesLines
* MFC r303213:kib2016-07-301-0/+1
| | | | | | Add missed required call to xo_finish() when only header is printed. Approved by: re (gjb)
* Fix CID 1011370 (Resource leak) in ps.truckman2016-05-251-6/+9
| | | | | | | | | | | | | There is no need to to call strdup() on the value returned by fmt(). The latter calls fmt_argv() which always returns a dynamically allocated string, and calling strdup() on that leaks the memory allocated by fmt_argv(). Wave some const magic on ki_args and ki_env to make the direct assignment happy. This requires a tweak to the asprintf() case to avoid a const vs. non-const mismatch. Reported by: Coverity CID: 1011370 MFC after: 1 week
* Use NULL instead of 0 for pointers.araujo2016-04-191-1/+1
| | | | | | kvm_open(3) will return NULL when it cannot access kernel virtual memory. MFC after: 2 weeks.
* Remove unused variable, this variable fmtstr was introduced at revision r225868araujo2015-06-011-6/+1
| | | | | | | and it is not used anymore after the convertion to use libxo at revision r283304. Differential Revision: D2678 Reviewed by: marcel
* Convert to use libxo. Document use of libxo as well.marcel2015-05-221-39/+62
| | | | | Obtained from: Phil Shafer <phil@juniper.net> Sponsored by: Juniper Networks, Inc.
* Prevent access to an uninitialized variablepfg2015-01-311-1/+1
| | | | | | | The "-h" option may access an uninitialized value. Prevent it by properly initializing the value. CID: 1006559
* Add -J to filter by matching jail IDs and names.bdrewery2014-05-021-3/+43
| | | | | | | | | | -J 0 can be used to show only host processes. Patch partially based on work by bz@ PR: bin/78763 MFC after: 2 weeks Relnotes: yes
* - Move 'showthreads' check out of fmt.c.jhb2013-01-191-1/+1
| | | | | - Update shadow copy of fmt_argv() prototype in w.c and fix calls for additional parameter.
* Include the thread name along with the command name when displaying thejhb2013-01-181-5/+6
| | | | | | | | | command name of a thread from a multi-threaded process that doesn't have an available argument list (such as kernel processes) and threads display is enabled via -H. Reviewed by: alfred, delphij, eric@vangyzen.net MFC after: 1 week
* Use kern.max_pid sysctl to obtain maximum PID number instead of using localpjd2012-12-121-3/+17
| | | | | | define. Reviewed by: jhb
* Avoid passing uninitialized stack to addelem() if called with an empty arg.emaste2012-08-291-2/+2
| | | | PR: bin/171174
* Spelling fixes for bin/uqs2012-01-071-1/+1
|
* No need in procfs(5).trociny2011-11-221-21/+0
| | | | MFC after: 2 weeks
* Make ps(1) automatically size its column widths.trasz2011-09-291-30/+73
|
* Fix some typos under bin/uqs2011-05-221-1/+1
| | | | Found by: codespell
* Get rid of DSIZ; instead just call the sizing function if provided.trasz2011-04-121-3/+3
|
* Initialize the execfile argument to NULL instead of _PATH_DEVNULL. This ↵brucec2010-02-081-1/+2
| | | | | | | | allows the -M option to be used without specifying -N. PR: bin/138146 Approved by: rrs (mentor) MFC after: 3 days
* Add the -d switch to the usage message.brian2009-07-231-1/+1
| | | | | | Submitted by: Emil Mikulic - emil at dmr dot ath dot cx Approved by: re (kib) MFC after: 1 week
* Remove redundant whitespacebrian2009-05-181-3/+2
|
* Add a -d option to ps to display descendant info with the output.brian2009-05-171-3/+129
| | | | | | This is similar to linux's -H (or -f) switch. MFC after: 3 weeks
* Remove unnessasary castkevlo2008-07-181-1/+1
|
* Teach ps(1) to parse pts TT values (i.e. '0', '1') for the -t flag.jhb2007-11-081-9/+23
| | | | | MFC after: 1 week Reported by: kris
* Introduce a way to make pure kernal threads.julian2007-10-261-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | kthread_add() takes the same parameters as the old kthread_create() plus a pointer to a process structure, and adds a kernel thread to that process. kproc_kthread_add() takes the parameters for kthread_add, plus a process name and a pointer to a pointer to a process instead of just a pointer, and if the proc * is NULL, it creates the process to the specifications required, before adding the thread to it. All other old kthread_xxx() calls return, but act on (struct thread *) instead of (struct proc *). One reason to change the name is so that any old kernel modules that are lying around and expect kthread_create() to make a process will not just accidentally link. fix top to show kernel threads by their thread name in -SH mode add a tdnam formatting option to ps to show thread names. make all idle threads actual kthreads and put them into their own idled process. make all interrupt threads kthreads and put them in an interd process (mainly for aesthetic and accounting reasons) rename proc 0 to be 'kernel' and it's swapper thread is now 'swapper' man page fixes to follow.
* - Move all of the PS_ flags into either p_flag or td_flags.jeff2007-09-171-2/+2
| | | | | | | | | | | | | | - p_sflag was mostly protected by PROC_LOCK rather than the PROC_SLOCK or previously the sched_lock. These bugs have existed for some time. - Allow swapout to try each thread in a process individually and then swapin the whole process if any of these fail. This allows us to move most scheduler related swap flags into td_flags. - Keep ki_sflag for backwards compat but change all in source tools to use the new and more correct location of P_INMEM. Reported by: pho Reviewed by: attilio, kib Approved by: re (kensmith)
* Sync program's usage() with manpage's SYNOPSIS.ru2005-02-091-3/+3
|
* Use statfs instead of getmntinfo(). This will make the procfs checkscsjp2004-11-191-9/+6
| | | | | | | play nicer in prisons. It also simplifies things. Reviewed by: rwatson Bumped into by: Jilles Tjoelker
* Currently if the user specifies -e and procfs is not mounted on /proc,csjp2004-11-141-0/+25
| | | | | | | | | | | printing of the process environment will fail silently. -define a function which will check to see if procfs is mounted on /proc -Implement this test if the user specified -e -If procfs is not mounted on /proc and -e was specified, print a warning. informing the user that procfs(5) is required. Reviewed by: wes, rwatson
* Removed bitrot.ru2004-11-131-12/+2
|
* Improve checking for `ps -t <dev>', and give better error messages whengad2004-06-271-8/+16
| | | | | an invalid <dev> is specified. Aside: It turns out that the S_ISCHR() check is true for almost every device that we have (not just tty's).
* Fix a bug I introduced by some last-minute changes in -r 1.102. I endedgad2004-06-241-1/+1
| | | | | | up checking the wrong variable for NULL. Submitted by: bde
* Rework the logic for `-t <tty>', such that it accepts "ttyp0" and "console",gad2004-06-241-15/+43
| | | | in addition to "/dev/ttyp0" or "p0" and "/dev/console" or "co".
* Change "struct varent" to use the standard queue(8) macros, instead ofgad2004-06-231-7/+7
| | | | | | using it's own version of the same basic algorithm. Submitted by: part by Cyrille Lefevre, part of it done by me
* Add a check for defunct processes in saveuser(), so the output for "args"gad2004-06-231-10/+18
| | | | | | | (aka "command") will display "<defunct>", as does the output from "comm" for those processes. Also do better checking for malloc() failures. Submitted by: Cyrille Lefevre
* Include the `-c' option in the usage() message.gad2004-06-231-1/+1
| | | | Submitted by: Cyrille Lefevre
* In the sorting routine, sort by thread-id if two processes have the same PID.gad2004-06-231-0/+2
| | | | Submitted by: Cyrille Lefevre
* Have the main() routine calculate %CPU and (if needed) memory informationgad2004-06-201-36/+29
| | | | | | | when copying per-process info before starting to sort the list. This way, sort-by-CPU or sort-by-memory will only calculate values once-per-process, instead of twice-per-comparison. Also take advantage of this to simplify the pscomp() routine.
* Try to change the isdigitch() macro to something that Bruce won't rollgad2004-06-011-3/+3
| | | | | his eyes at quite so much... (actually someone else pointed this out to me a long time ago, but apparently I never fixed it)
* A few more style-fixes from Bruce. The only non-cosmetic changegad2004-06-011-16/+9
| | | | | | is to drop a call to setuid() which has not been needed for years. Noticed by: bde
* Since I'm not ready to add the non-standard ADD_PS_LISTRESET feature,gad2004-06-011-26/+1
| | | | | remove the #ifdef for it for now. I might add the feature for real at some later date, there isn't much reason for the #ifdef for now.
* Make a few style-istic improvements to the previous commits.gad2004-06-011-16/+15
| | | | Noticed by: bde
* Fix so `ps' catches and complains about null-values specified for agad2004-06-011-3/+8
| | | | | | | process id, instead of using pid==0. Ie, `ps -p 12,' and `ps -p ,12' are now errors (instead of being treated like `ps -p 0 -p 12'). Noticed by: Cyrille Lefevre on freebsd-arch
* Additional tiny adjustment to kludge-option processing so `ps t p0'gad2004-06-011-6/+7
| | | | | | | | is treated like `ps -t p0', instead of changing it to `ps -T p0'. Note that `ps t' is still changed to `ps -T', since that is one of the main reasons for this kludge processing... Noticed by: Jilles Tjoelker on freebsd-arch
* Rewrite the kludge-option processing to improve how it handles a fewgad2004-06-011-62/+91
| | | | | | | | | | | | | | | | | | | | more special situations. This is the code which process `ps blah', when "blah" does not include a leading '-'. This change also removes a long-undocumented BACKWARD_COMPATIBILITY compile-time option, where: ps -options arg1 arg2 (with no '-' on "arg1" and "arg2") was treated as: ps -options -N arg1 -M arg2 This also changes `ps' to check for any additional arguments after processing all the '-'-options, and attempt to use those arguments as a pid or pidlist. If an extra argument is not a valid pidlist, then `ps' will print an error and exit. This seems a more generally useful extension of the kludge-option processing than the -N/-M behavior, and has fewer confusing side-effects. Reviewed by: freebsd-arch
* Add the 'sid' info to the output of `ps -j', to make up for the 'sess'gad2004-05-231-1/+1
| | | | | | | (session-pointer) info which was dropped from `ps' earlier in 5.x. PR: bin/59423 Submitted by: Jilles Tjoelker
* Fix the kludge-old-options processing so `ps tpt' will be treated thegad2004-05-231-4/+5
| | | | | | | | same as `ps -tpt', instead of being changed into `ps -tpT'. PR: bin/52489 Submitted by: Jilles Tjoelker MFC after: 1 week
* Change `ps' to use the KERN_PROC_RGID and KERN_PROC_SESSION optionsgad2004-05-221-8/+5
| | | | | | | | (if trying to match only one real-group or one session-id), now that those options are implemented in src/sys/kern/kern_proc.c (v1.203). PR: bin/65803 (a very tiny piece of the PR) Submitted by: Cyrille Lefevre
* Remove clause 3 from the UCB licenses.markm2004-04-061-4/+0
| | | | OK'ed by: imp, core
* Drop the include of <stdint.h>, since r1.84 removed references of intmax_t.gad2004-04-041-1/+0
|
* Add back the `-e' option, which was mistakenly dropped when cleaninggad2004-04-041-1/+1
| | | | | up the PS_ARGS string in revision 1.69 (and which was apparently not missed by anyone...).
* Give a name of 'l' (list) to the union in struct listinfo. This isgad2004-04-041-28/+30
| | | | | because some compilers (such as gcc 2.95.4) do not support having an unnamed union for a field in a struct.
OpenPOWER on IntegriCloud