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).
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
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.
- 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)
the header title string "bar" extends to the end of the argument
even if it contains commas or spaces, unlike in RELENG_4 or earlier.
The modern syntax agrees with SUSv3.
MFC after: 3 days
all column-headers to print in lowercase by default. I was in too
much of a rush in committing 1.75, and didn't notice that the case
had changed. This time I did considerably more testing, and used
'diff' instead of just quickly eyeballing the results...
Apologies. I expect this means the dunce cap is mine for awhile.
If this doesn't work, I'll just drop back to 1.72 and hide under
my desk for awhile.
the user specifies a keyword which is an alias to some other keyword.
E.g.: stat (for state) or pcpu (for %cpu)..
Submitted by: Kostik Belousov
MFC plans: "soon"
output-format keyword, and the keyword they picked is an alias to
some other keyword. E.g.: ps -o stat=Zustand $$
('stat' is defined as an alias for 'state')
PR: bin/57833
MFC after: 3 weeks
- Document the fact that empty heading text suppresses the
heading line (e.g. 'ps -o pid='), as this is very useful
in scripts.
- Describe logname keyword more completely.
- Describe the printing of arguments more completely.
- Put lockname in the correct alphabetical order in the list
of all keywords.
- Correct sentence in standards section.
Submitted by: Jilles Tjoelker <jilles at stack nl>
PR: docs/73618
MFC After: 1 week
to exceed 10 megabytes in size (especially in X), bump the max
column width from 4 bytes to 5. This will make the ps auxw output
uniform again when a process's rss exceeds 10 megs.
It should be noted that when 5 digits becomes to small, other
solutions should be explored such as displaying them in megabytes
or having ps automatically re-size column widths.
Discussed with: gad
MFC after: 1 week
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
(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
threads, put the command name in square brackets instead of parenthesis.
This matches NetBSD, and also seems to be what linux does. The sentence
which is added to the man page is taken straight from NetBSD.
PR: bin/65803
Submitted by: Cyrille Lefevre
Obtained from: NetBSD
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
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...)
and number-of-threads tied to a process. Result can be seen by typing,
e.g.: ps -HO lwp,nlwp
These new options are not documented yet. More options will be coming,
and I will update the man page after I get farther along.
PR: bin/65803 (though adjusted to fit our present source)
Submitted by: Cyrille Lefevre
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.
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
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
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
(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
This corrects a problem of lost-precision for `-r' (sort-by-CPU). Also,
for sort-by-CPU and sort-by-memory, any processes which have the same
value CPU or MEMORY are now sorted by TTY and then (if needed) by pid.
(* - I just added the NODEV checks, after doing some testing of my own)
Submitted by: bde
MFC after: 1 week
(if any) and exit, thus matching the behavior on -stable and other OS's.
My earlier attempt to fix this (v1.65) only seemed to work because of a
lucky random value in nentries (which was not being initialized back
when I tested that earlier patch).
is compiled with LAZY_PS, so that there is only one PS_ARGS string to
modify when changing the option-list. Also get `-f' to show up in the
usage() statement when compiled with LAZY_PS.
- Change `-p' to allow a list of process IDs, and `-t' to allow a list
of terminal names, instead of only a single value for each.
- Add the `-A' option of SUSv3, which is exactly the same as `-ax'.
- Add the `-G gidlist' (group id).
- Allow any of these "selector options" to be specified multiple times,
and have `ps' keep adding to a given list -- instead of replacing the
previously-specified values.
- Fix interactions between selector-options, so that: "If any are
specified, ... ps shall select the processes represented by the
inclusive OR of all the selection-criteria options." (from SUSv3)
- Add a `-X' option, which is the reverse of the `-x' option.
- various minor improvements in parsing and error handling.
This does not get us to match POSIX/SUSv3, but it gets us closer. The
`-g pgidlist', `-R ruserlist' and `-s sidlist' options mentioned in
freebsd-standards are still under debate, so they skipped for now.
It should be true that this introduces no user-visible incompatible
changes, except to support "new stuff" that was not supported before.
sysctl(3) interface in kvm(3).
- Document the correct default when no -N is specified.
- Remove stale reference to /var/db/kvm_kernel.db.
- Remove stale reference to /var/run/dev.db.
just print the header (if any) and exit, thus matching the behavior on -stable
and other OS's.
Also adds support for <x> being a comma-separated list of processes, and does
a much better checking for invalid-values of <x>, such as 'ps -p someword'.
Reviewed by: mentioned on freebsd-current
MFC after: 10 days
* Remove mention of '>', 'A', and 'S' states
* Mention 'W' state.
* List 'J' state in the correct location.
* Sync with flags in sys/proc.h
Approved by: rwatson (mentor)
MFC after: 7 days
one that is already there. This is consistent with GNU ps(1)'s BSD mode, and
POLA.
Reported by: Andy Farkas <andyf@speednet.com.au>
Tested by: Andy Farkas <andyf@speednet.com.au>
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