Commit Graph

113 Commits

Author SHA1 Message Date
Jilles Tjoelker
2aff415a8c ps: Fix memory leak when showing start/lstart for swapped-out process.
Spotted by:	scan-build (uqs)
2012-07-15 15:22:13 +00:00
Ed Schouten
6aed20fe1a Remove unused variables.
Simply annotate the function parameters with __unused, instead of adding
the ve-variables. This makes the code build with GCC 4.7 and -Werror.
2012-01-17 22:17:10 +00:00
Edward Tomasz Napierala
aa7a15b6bb For processes with no controlling terminal, display "-" in the TTY column
instead of "?".

Submitted by:	arundel
2011-10-30 15:21:27 +00:00
Edward Tomasz Napierala
1d1143ec27 Make ps(1) automatically size its column widths. 2011-09-29 06:31:42 +00:00
Ed Schouten
9f365aa1d6 Get rid of major/minor number distinction.
As of FreeBSD 6, devices can only be opened through devfs. These device
nodes don't have major and minor numbers anymore. The st_rdev field in
struct stat is simply based a copy of st_ino.

Simply display device numbers as hexadecimal, using "%#jx". This is
allowed by POSIX, since it explicitly states things like the following
(example taken from ls(1)):

	"If the file is a character special or block special file, the
	size of the file may be replaced with implementation-defined
	information associated with the device in question."

This makes the output of these commands more compact. For example, ls(1)
now uses approximately four columns less. While there, simplify the
column length calculation from ls(1) by calling snprintf() with a NULL
buffer.

Don't be afraid; if needed one can still obtain individual major/minor
numbers using stat(1).
2011-09-28 18:53:36 +00:00
Bjoern A. Zeeb
925af54487 Rename ki_ocomm to ki_tdname and OCOMMLEN to TDNAMLEN.
Provide backward compatibility defines under BURN_BRIDGES.

Suggested by:	jhb
Reviewed by:	emaste
Sponsored by:	Sandvine Incorporated
Approved by:	re (kib)
2011-07-18 20:06:15 +00:00
Edward Tomasz Napierala
9acd91270f Add "gid" and "group" keywords to display the effective group ID
and effective group name.  Also, add "egid", "egroup" and "euid" aliases.

PR:		bin/146331
Submitted by:	Jeremie Le Hen <jeremie at le-hen dot org>
2011-06-14 16:50:16 +00:00
Edward Tomasz Napierala
f9db2550b2 Add proper width calculation for time fields (time, cputime and usertime).
This fixes the ugly overflow in "ps aux" output for "[idle]".
2011-03-24 20:15:42 +00:00
Edward Tomasz Napierala
3bf92decd3 Make "LOGIN" and "CLASS" columns width scale properly instead of wasting space. 2011-03-24 17:20:24 +00:00
Konstantin Belousov
a870bf2c31 Implement the usertime and systime keywords for ps, printing the
corresponding times reported by getrusage().

Submitted by:	Dan Nelson <dnelson allantgroup com>
MFC after:	1 week
2011-03-17 11:25:32 +00:00
Edward Tomasz Napierala
7123f4cd6f Export login class information via kinfo and make it possible to view
it using "ps -o class".
2011-03-05 14:41:49 +00:00
Konstantin Belousov
50a57dfbec Move repeated MAXSLP definition from machine/vmparam.h to sys/vmmeter.h.
Update the outdated comments describing MAXSLP and the process
selection algorithm for swap out.

Comments wording and reviewed by:	alc
2011-01-09 12:50:44 +00:00
Juli Mallett
41ded75de8 o) Add a keyword to displaying elapsed time in integer seconds, "etimes".
o) Give slightly better (i.e. any) documentation of the format of "etime".

Reviewed by:	jilles
2010-03-17 22:57:58 +00:00
Jilles Tjoelker
6dcfa92ee8 Fix elapsed (etime) field for swapped out processes in ps:
show '-' instead of time since the Epoch.

PR:		bin/123069
Submitted by:	Vladimir Kozbin
Approved by:	ed (mentor)
MFC after:	3 weeks
2009-05-24 15:32:34 +00:00
Brian Somers
044fce530f Add a -d option to ps to display descendant info with the output.
This is similar to linux's -H (or -f) switch.

MFC after:	3 weeks
2009-05-17 04:00:43 +00:00
Attilio Rao
4610a8114d [1] When showing threads, the thread name just appears if the comm
label is choosen as last printout (ucomm suffers of this such bug
	too).  That bug is caused by the fact that the fixed size of
	printout doesn't leave enough space for them to be printed out.
	Implement ucomm and comm commands with a dynamic size lenght for
	buffers.

[2]	On AMD64 architecture pointers don't have enough chars space to
	be shown (8 chars while they need 16).  Fix them by providing
	a variadic space so that it fits well on both 64 and 32 bits
	architectures.

[3]	Check a return value of malloc() that wasn't checked before.

PR:		bin/128841, bin/128842
Reviewed by:	jhb, emaste
Sponsored by:	Sandvine Incorporated
2009-02-26 18:01:07 +00:00
Ed Maste
160bda3652 Fix whitespace. 2008-11-13 15:06:34 +00:00
Julian Elischer
7ab24ea3b9 Introduce a way to make pure kernal threads.
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.
2007-10-26 08:00:41 +00:00
Jeff Roberson
b61ce5b0e6 - Move all of the PS_ flags into either p_flag or td_flags.
- 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)
2007-09-17 05:31:39 +00:00
Olivier Houchard
7bd5296d29 For pts, print the pts number, instead of the full name. As it was, we ended
up always printing "pts".

Submitted by:	Michal Mertl <mime at traveller dot cz>
2006-02-21 13:02:18 +00:00
Tim J. Robbins
2c61418d05 Use warn() instead of perror(). 2004-07-20 05:52:00 +00:00
Garance A Drosehn
70548f642a Change the "rtprio" format so it prints an informative string for
the PRI_ITHD case (instead of just printing the digit '1').

Submitted by:	Cyrille Lefevre
2004-06-27 23:59:38 +00:00
Garance A Drosehn
bdf8ab4692 Change "struct varent" to use the standard queue(8) macros, instead of
using it's own version of the same basic algorithm.

Submitted by:	part by Cyrille Lefevre, part of it done by me
2004-06-23 23:48:09 +00:00
Garance A Drosehn
4e8a8d9f85 Avoid padding the value of "ucomm" when it is the last column in the line.
Submitted by:	Cyrille Lefevre
2004-06-23 12:18:36 +00:00
Garance A Drosehn
820434b27f Make sure the value of "upr" (scheduling priority on return from system call)
is scaled in the same way that "pri" (scheduling priority) is scaled.

Submitted by:	Cyrille Lefevre
2004-06-23 11:56:57 +00:00
Garance A Drosehn
16ac318df7 Have `ps' return the cputimes for zombies, with the assumption that
kvm_getprocs() will provide useful information if it can, or *it*
will provide a zero value if it can not find something appropriate.

Submitted by:	bde
2004-06-21 16:53:11 +00:00
Garance A Drosehn
15b87b531e Add the `-O emul' format option, which prints the name of the system-call
emulation environment the process is in.  "emul" as a keyword is picked
up from OpenBSD.

PR:		bin/65803
Submitted by:	Cyrille Lefevre
2004-06-20 23:40:54 +00:00
Garance A Drosehn
ce1affa2ac From SUSv3:
Any [standard output] field need not be meaningful in all
    implementations. In such a case a hyphen ('-') should be
    output in place of the field value

So have the `-O label' option print out the string "  -" if the
process has no label.

Approved by:	Silence from rwatson and green (when asked in March...)
2004-06-20 22:31:37 +00:00
Mark Murray
6195fb4102 Remove clause 3 from the UCB licenses.
OK'ed by:	imp, core
2004-04-06 20:06:54 +00:00
Garance A Drosehn
3998d22271 Fix `-o rtprio' so it prints the correct value.
PR:		bin/59417
Submitted by:	Jan Willem Knopper
This fix by:	bde (in the audit-trail of the PR)
2004-03-28 02:13:31 +00:00
Hartmut Brandt
de244df7c9 Implement the nwchan keyword that has been in the man page, but was
not implemented. This is just handy if you want to ddb the address
some process is waiting on.
2003-08-13 07:35:07 +00:00
Philippe Charnier
2d5506c942 Revert the zombie part of previous commit 2003-04-15 18:49:20 +00:00
Philippe Charnier
b85add5f31 Correct style bugs. Don't skip zombies in cputime(), according to Bruce,
zombie CPU times are valid. Adjust array size in strftime(3).

Submitted by:	Bruce
2003-04-14 19:51:36 +00:00
Tim J. Robbins
e2c9ac698c Display residency and sleep times (re and sl fields) larger than 127 as 127.
This is what the manual page says ps should do, and what OpenBSD and NetBSD do.
Based on a patch from Ken Stailey.

PR:		27433, 46232
2003-04-12 10:39:56 +00:00
Philippe Charnier
eaed5652bf Display elapsed time (-o etime) using [[dd-]hh:]mm:ss, which according to
Solaris man page is the POSIX way.

Reviewed by:	jmallett
2003-02-05 13:18:17 +00:00
Juli Mallett
78b1878a16 Per-variable\ entry headers, to allow the 'ps -otime -otime=FOO' or similar
case to do the right thing and affect exactly one column.  This is consistent
with GNU ps(1) in BSD mode, and POLA.
2003-01-19 00:31:16 +00:00
Juli Mallett
775bba9fd8 Refer to the process label as proclabel, as there is a function called label,
and that's what these locals were called before.
2003-01-18 03:31:30 +00:00
Tim J. Robbins
01e5f16641 Do not print a header line if it would be empty; required by 1003.1-2001. 2002-10-31 13:41:37 +00:00
Robert Watson
2af538eb48 Use the MAC interface to list process MAC labels rather than using
the LOMAC-specific interface (which is being deprecated).  The
revised LOMAC using the MAC framework will export levels listable
using this mechanism.

Approved by:	re
Obtained from:	TrustedBSD Project
Sponsored by:	DARPA, Network Associates Laboratories
2002-10-24 00:00:57 +00:00
John Baldwin
0d6326492b Catch up to SMTX -> SLOCK changes. 2002-10-02 20:33:52 +00:00
Juli Mallett
362d62ba07 Rename new PLONG type to PGTOK as the conversion is more important than the
size (which is mostly undefined anyway).

Submitted by:	bde
2002-09-17 17:13:52 +00:00
Juli Mallett
760bbf7d6d Conglomerate printing of ps_pgtok'd data into a PLONG type. I couldn't think
of a better name, except PINT, but I decided to go with assuming LONG to
be safe, rather than assuming INT.
2002-09-17 02:52:44 +00:00
Juli Mallett
f3073b05b7 Perform keyword.c:1.27 properly, implement -orss in the New World Order of
ps(1) formatting, using pgtok() to get the value in K, rather than printing
it in pages.  This is consistent with behaviour before keyword.c:1.26 (et al)
which exists in STABLE today, and which uses the same metric as VSZ.

Submitted by:	bde
2002-09-16 20:19:51 +00:00
Peter Wemm
6327ab9cd1 Do not risk using the kernel pgtok() which assumes the page size is
constant.
2002-09-13 07:13:33 +00:00
Bruce Evans
c1f903a031 Fixed a printf format error that was fatal on alphas. Adding WFORMAT=0
to the Makefile didn't affect this bug because WFORMAT only controls
higher- level format checking (not the -Wformat that is implicit in
-Wall).

Fixed a nearby printf format error that was benign and 3 nearby style bugs.
2002-07-11 17:28:29 +00:00
Juli Mallett
ffe25988bd Make printval() take a 'void *' thus negating any assumptions the compiler
may try to make about the alignment of the dereferenced datum.
2002-07-07 21:45:59 +00:00
David E. O'Brien
2749b14129 Consistently use FBSDID 2002-06-30 05:15:05 +00:00
Juli Mallett
c3f1b5a9db Cast to long to match format. Hidden by revision 1.18 of Makefile. 2002-06-07 00:00:29 +00:00
Juli Mallett
ba2cd77062 Use a global `now' variable for the current time, and initialise it at
startup, right after calling setlocale(3).
2002-06-06 21:21:25 +00:00
Juli Mallett
76e1a9fe48 Implement a SUSv3-ignorant but "time"-similar format for "etime", elapsed
run time (NOT cpu time).  cputime() and elapsed() both need to honour SUSv3
now.
2002-06-06 21:18:37 +00:00