Commit graph

167 commits

Author SHA1 Message Date
Simon J. Gerraty 7cf3a1c6b2 Updated dependencies 2013-03-11 17:21:52 +00:00
Simon J. Gerraty f5f7c05209 Updated dependencies 2013-02-16 01:23:54 +00:00
David E. O'Brien d9a447559b Sync with HEAD. 2013-02-08 16:10:16 +00:00
John Baldwin 9f0b6e5e27 - Move 'showthreads' check out of fmt.c.
- Update shadow copy of fmt_argv() prototype in w.c and fix calls for
  additional parameter.
2013-01-19 00:21:55 +00:00
Xin LI c3a1bb32f4 Set showthread = 0 for w(1).
X-MFC:	together with r245610
2013-01-18 23:54:27 +00:00
Ed Schouten dbd1414ddc Fix whitespace.
MFC after:	1 week
2012-11-17 16:47:05 +00:00
Simon J. Gerraty 23090366f7 Sync from head 2012-11-04 02:52:03 +00:00
Ed Maste b6eec535d3 Use CLOCK_UPTIME to get the uptime. 2012-10-12 15:03:28 +00:00
Eitan Adler eae8be706e Bump date missed in r202756
PR:		docs/171624
Submitted by:	bdrewery
Approved by:	gabor
MFC after:	3 days
2012-09-14 17:50:42 +00:00
Marcel Moolenaar 7750ad47a9 Sync FreeBSD's bmake branch with Juniper's internal bmake branch.
Requested by: Simon Gerraty <sjg@juniper.net>
2012-08-22 19:25:57 +00:00
Ed Schouten d11cba9c89 Add missing static keywords to w(1) 2011-11-06 08:18:47 +00:00
Ed Schouten 21632754d6 Only print entries for which ut_host points to a character device.
Now that we use utmpx, we more often have entries for which the ut_line
is left blank. To prevent us from returning struct stat for "/dev/",
check that the resulting stat structure belongs to a character device.
2011-07-05 14:12:48 +00:00
Joel Dahl da52b4caaf Remove the advertising clause from UCB copyrighted files in usr.bin. This
is in accordance with the information provided at
ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change

Also add $FreeBSD$ to a few files to keep svn happy.

Discussed with:	imp, rwatson
2010-12-11 08:32:16 +00:00
Rebecca Cran c08dcaf147 Initialize the execfile argument to NULL instead of _PATH_DEVNULL. This allows the -M option to be used without specifying -N.
PR:	bin/138146
Approved by:	rrs (mentor)
MFC after:	3 days
2010-02-08 21:23:48 +00:00
Ed Schouten 0806dd9238 Remove stale references to utmp(5) and its corresponding filenames.
I removed utmp and its manpage, but not other manpages referring to it.
2010-01-21 17:25:12 +00:00
Ed Schouten 1131779fb3 Port w(1) to utmpx.
Let it print "-" when the TTY string is empty. In this case, it must
also make sure it doesn't match processes who also have no controlling
TTY. Otherwise it will print random kernel processes when trying to pick
the best matching process.

Eventually it should look at the value of ut_pid as well.
2010-01-13 18:09:21 +00:00
David Malone 54767bf590 This now passes a make universe with WARNS=6. 2010-01-07 09:47:05 +00:00
David Malone 02f563767b Shuffle parens to avoid type-punning warning. 2010-01-05 21:00:23 +00:00
Ed Schouten b7946da96b Build usr.bin/ with WARNS=6 by default.
Also add some missing $FreeBSD$ to keep svn happy.
2010-01-02 10:27:05 +00:00
Xin LI 821df508e8 Revert most part of 200420 as requested, as more review and polish is
needed.
2009-12-13 03:14:06 +00:00
Xin LI 6f2d322192 Remove unneeded header includes from usr.bin/ except contributed code.
Tested with:	make universe
2009-12-11 23:35:38 +00:00
Ed Schouten dc65bcacb2 Let w(1) use utmpx.
We don't have UT_*SIZE anymore. One of the reasons for that is because
all strings are null terminated, there is no need for apps to copy
strings out of the utmpx structure. This means we can define W_DISP*SIZE
lengths for all columns.

While there, adjust the sizes a little. Steal some bytes from the
username column, while extending the hostname column quite a bit.
2009-12-06 01:10:30 +00:00
Hajimu UMEMOTO b94f6865f9 When -n is specified, attempt to turn hostnames found in utmp into IP
addresses, again.  However, change a hostname into an IP address, only
when a host has just one A/AAAA RR.

Requested by:	candy__at__kgc.co.jp
MFC after:	2 weeks
2009-11-22 16:51:44 +00:00
Xin LI 277dbce981 Constify format string pointer, otherwise this would trigger warning when
higher warning level is enabled.
2009-09-08 01:11:23 +00:00
Hajimu UMEMOTO 34903a55c3 Fix the problem that the entry broke into two lines with multi-byte
AM/PM format.

Reported by:	takawata
2009-08-30 11:17:42 +00:00
Andrey A. Chernov e39ee4216c w(1) uses strftime %b with to print the abbreviated month name
if a user logged in more than a week ago.
This may contain multibyte characters (e.g. when using UTF-8).
This string is then aligned on byte-length rathern than char-length,
resulting in misalignment and unfinished multibyte characters.

PR:             126657
Submitted by:   Johan van Selst <johans@stack.nl>
2008-08-20 12:32:19 +00:00
Ruslan Ermilov 89273e7b6c Fix markup. 2006-12-14 19:02:48 +00:00
Poul-Henning Kamp bec1fa8607 Use sysctlbyname 2006-05-11 17:25:36 +00:00
Andre Oppermann a21cbcb876 Obtain true uptime through clock_gettime(CLOCK_MONOTONIC, struct *timespec)
instead of subtracting 'bootime' from 'now'.

Sponsored by:	TCP/IP Optimization Fundraise 2005
2005-10-17 15:37:22 +00:00
Garance A Drosehn b8eb1eccee Use the ki_udata field that was recently-added to kinfo_proc, instead of
stealing ki_spare[0] to hold a pointer.
2005-06-04 23:40:09 +00:00
Ruslan Ermilov 0227791b40 Expand *n't contractions. 2005-02-13 22:25:33 +00:00
Ruslan Ermilov 6c7216df78 Sort sections. 2005-01-18 13:43:56 +00:00
Bruce Evans 929789b42c Include <sys/proc.h> instead of depending on namespace pollution in
<sys/user.h> for the definition of TDF_SINTR.  Fixed anachronous
spelling of TDF_SINTR in a comment

Demangled VCS ids.  There were 2 misplaced copies of $FreeBSD$ and of
the include before it.  The vendor id infrastructure was edited.

Fixed the only other remaining style bug since rev.1.1 (expansion of
struct member names made a line too long).
2004-04-14 09:34:17 +00:00
Philippe Charnier 69fe77ce99 Do not print the result of strftime() in case of failure, the content is
indeterminate in such a case. The correct value for 2nd argument is
sizeof(buf). Do not NUL-terminate the result string, strftime() will do it
for us.
2003-09-07 16:31:32 +00:00
Peter Wemm c76b41b7b5 utmp.ut_time is not a time_t, do not pass a pointer to it to pr_attime(). 2003-06-28 19:11:42 +00:00
Sean Chittenden d0d0355e4d Fix warning when calling w(1) when logged in via xdm/kdm. This is
really a problem with utmp/wtmp, but takes the same approach as who(1).

Reviewed by:	knu (mentor), mini, silence on -audit
Approved by:	knu (mentor), mini
2002-08-23 04:31:58 +00:00
Juli Mallett e8e649cc5d ANSI style function declarations. 2002-06-07 01:41:54 +00:00
Josef Karthauser 1063e12617 Replace /kernel with /boot/kernel/kernel.
PR:		docs/37757
Submitted by:	Hiten Pandya <hiten@uk.FreeBSD.org>
2002-05-09 11:47:42 +00:00
Warner Losh 3f330d7d1a remove __P 2002-03-22 01:42:45 +00:00
David E. O'Brien 716ced0b62 Back out part of rev 1.51. The lesser impact fix is to just remove
the unused global var.
2002-03-07 22:36:56 +00:00
Mark Murray 8b56c58be4 WARNS=2 fix, use __FBSDID() and sort includes.
WARNS=2 not added to Makefile as it is to become default.
2001-12-11 22:18:47 +00:00
Bruce Evans 6eabd84580 Compensate for "Compensate for header dethreading" by backing it out. 2001-10-10 17:48:44 +00:00
Crist J. Clark cfd848db6f Fixing a bug that causes very short uptimes (less than one minute) to
be 30 seconds off. (Thanks to Vladimir B.Grebenschikov
<vova@express.ru> for the PR and ru for a more elegant fix.)

PR:		bin/30680
Approved by:	ru
2001-09-22 09:33:00 +00:00
Julian Elischer b40ce4165d KSE Milestone 2
Note ALL MODULES MUST BE RECOMPILED
make the kernel aware that there are smaller units of scheduling than the
process. (but only allow one thread per process at this time).
This is functionally equivalent to teh previousl -current except
that there is a thread associated with each process.

Sorry john! (your next MFC will be a doosie!)

Reviewed by: peter@freebsd.org, dillon@freebsd.org

X-MFC after:    ha ha ha ha
2001-09-12 08:38:13 +00:00
Brian Somers 5b718312b7 When -n is specified, don't attempt to turn hostnames found in utmp
into addresses as we have no idea what address family they belong to.

When -n is not specified, resolve IPv6 as well as IPv4 addresses found
in the host field of utmp.  Use realhostname_sa() to resolve addresses
(the old code was wrong).

Rename ``x'' to ``x_suffix'' to avoid confusion.

Hard code the host column width to 16 (against the imminent increase
of UT_HOSTSIZE in utmp.h).
2001-07-26 19:20:13 +00:00
Dima Dorfman f247324df7 Remove whitespace at EOL. 2001-07-15 08:06:20 +00:00
Ruslan Ermilov 625003720a mdoc(7) police: removed HISTORY info from the .Os call. 2001-07-10 14:16:33 +00:00
Poul-Henning Kamp c59c7f97ad Call kvm_close() before exit for consistency.
PR:		24654
Submitted by:	Daniel Hemmerich zartik@yahoo.com
2001-05-28 21:30:31 +00:00
Thomas Moestl af943f55f7 Fix the error buffer passed to kvm_openfiles to have a correct length
of _POSIX2_LINE_MAX.

MFC after:	1 week
2001-05-26 00:02:13 +00:00
Mark Murray 6e547eabb8 Compensate for header dethreading. 2001-05-01 08:46:02 +00:00
Ruslan Ermilov dc12be5258 MAN[1-9] -> MAN. 2001-03-27 10:52:19 +00:00
Andrey A. Chernov 9575fb2f65 Fix width for printing time 2001-03-21 21:49:33 +00:00
Andrey A. Chernov 2742fc8eb2 Preserve comma as separator when it is not equal to radix character 2001-03-03 16:47:07 +00:00
Andrey A. Chernov e25fd27cd1 Don't use "," as load avg. separator because it can be precision point in some
locales, so leads to confusion
2001-03-03 01:32:46 +00:00
Andrey A. Chernov 5f2de0a78a Oops, remove tabs sneaked in wrong place 2001-03-02 23:49:07 +00:00
Andrey A. Chernov 000346454c Use AM/PM time only when available in locale 2001-03-02 23:11:38 +00:00
John Baldwin f5ace77533 Catch up to proc flag changes. 2001-01-24 14:28:24 +00:00
Brian Somers 3b93c7437b Hostnames are case-insensitive 2000-12-22 15:21:06 +00:00
Brian Somers 3bebe99135 If the utmp login time is greater than the tty atime, use it to calculate
the idle time instead of the atime.

This makes entries for people that have logged in but done nothing
else show up correctly.

Reviewed by: markk@knigma.org
2000-12-21 01:30:47 +00:00
Ruslan Ermilov 9b88faecd3 Prepare for mdoc(7)NG. 2000-12-19 16:00:12 +00:00
Kirk McKusick 1f7d250182 Change the proc information returned from the kernel so that it
no longer contains kernel specific data structures, but rather
only scalar values and structures that are already part of the
kernel/user interface, specifically rusage and rtprio. It no
longer contains proc, session, pcred, ucred, procsig, vmspace,
pstats, mtx, sigiolst, klist, callout, pasleep, or mdproc. If
any of these changed in size, ps, w, fstat, gcore, systat, and
top would all stop working. The new structure has over 200 bytes
of unassigned space for future values to be added, yet is nearly
100 bytes smaller per entry than the structure that it replaced.
2000-12-12 07:25:57 +00:00
Ruslan Ermilov 8fe908ef0c mdoc(7) police: use the new features of the Nm macro. 2000-11-20 19:21:22 +00:00
Peter Wemm 6ff4ec180d Use the same technique as ps(1) to avoid the need for setgid. (ie: use
/dev/null as the default kernel and /dev/mem filenames, but still allow
the usual overrides)
1999-11-17 15:28:45 +00:00
David Nugent 658248453e Fix cosmetic bug in time display. Current day logins are now displayed
as plain time as originally intended, instead of displaying DayHH times
when the login time happens to be prior the GMT - TZ difference.
(Only noticable on systems operating east of GMT/UTC).
Local times are now used to determine the day.
1999-11-10 04:28:16 +00:00
Peter Wemm c3aac50f28 $Id$ -> $FreeBSD$ 1999-08-28 01:08:13 +00:00
Brian Feldman ac3cd5208b New w ability: you can list multiple users on the command line and it will
match with all of them, rather than only supporting a single user.

PR:		11121
Kinda submitted by:	James Howard <howardjp@byzantine.student.umd.edu>
Reviewed by:		DES
1999-07-28 19:29:46 +00:00
Nik Clayton 3be5f1f5ce Add $Id$, to make it simpler for members of the translation teams to
track.

The $Id$ line is normally at the bottom of the main comment block in the
man page, separated from the rest of the manpage by an empty comment,
like so;

     .\"    $Id$
     .\"

If the immediately preceding comment is a @(#) format ID marker than the
the $Id$ will line up underneath it with no intervening blank lines.
Otherwise, an additional blank line is inserted.

Approved by:            bde
1999-07-12 20:24:20 +00:00
Bill Fumerola 9ef5c48bef Clean up some ambiguous nested if/elses. 1999-07-04 17:26:16 +00:00
Andrey A. Chernov 9587fac012 fix -n with 16-chars hostnames, modified patch from PR
PR: 11286
Submitted by:  Hans Huebner <hans@chaosradio.berlin.ccc.de>
1999-04-22 23:40:56 +00:00
Brian Somers 0cadb9cad6 Get things right for tty names of length UT_LINESIZE.
Cosmetic: Don't shadow the `p' variable.
          Remove two unused variables.
PR:	3638
1999-03-31 21:01:39 +00:00
Peter Wemm 69b41093b5 Fix the annoying bug introduced in rev 1.18 that caused each line to be
one character shorter than the previous in a stairstep fashion when long
idle times were involved.

A couple of nits:
- spelling/typo fix.
- some of the easier style(9) fixes where it was bothering me.
- Handle 100+ days idle time (ha!).  Probably the right thing to do is
  to do a snprintf into a buffer and strlen the result rather than doing
  hackery on magic numbers.

XXX the wide (and mostly unused) username and tty columns annoy me since
it it could be used for more useful information for the command. We should
actually count the largest username and tty and adjust like 'ls -l' does.
1999-01-10 15:28:37 +00:00
Matthew Dillon a4f33f438d No __profname bozoness, no strstr() bozoness... test argv[0] against
"uptime" the right way.  Sheesh.
1998-12-24 23:27:33 +00:00
Steve Price 0d5ad2d7ff Since argv is in scope, use argv[0] instead of __progname.
Suggested by:	bde
1998-12-24 18:20:58 +00:00
Steve Price a288ccca56 Do a better job of determining if we were called as uptime(1).
PR:		8593
1998-11-09 01:19:30 +00:00
Warner Losh fd67e2c50e Remove unused strvisx. 1998-06-09 04:35:20 +00:00
Joseph Koshy a88d7a8297 Cosmetic fix. Compute header field widths from UT_{HOST,LINE,NAME}SIZE
instead of hardcoding header line.

PR: 6325
1998-05-21 08:46:48 +00:00
Joseph Koshy bc53c0a6b2 Allow `w' to treat a corrupted "utmp" as a non fatal error.
PR: bin/2832
1998-05-14 10:13:24 +00:00
Poul-Henning Kamp 3d65e4d1f8 Like most Unices FreeBSD should have a larger tty field at least
as large as UT_LINESIZE (/usr/include/utmp.h). If the tty name is logged
with this size why isn't the w command reporting it?

(We should probably report the tty/cua prefix then as well ? /phk)

PR:		4187
Reviewed by:	phk
Submitted by:	Jorge M. Goncalves <ee96199@tom.fe.up.pt>
1998-04-19 18:32:01 +00:00
Steve Price a76f172954 Reword using who.1 as a good example of where to start.
Submitted by:	bde
1998-03-22 17:39:08 +00:00
Steve Price de48a0f797 Reword the synopsis line so that it makes sense. 1998-01-12 00:47:52 +00:00
Alexander Langer 8109e672e4 -Wall cleanup. 1997-12-28 17:50:10 +00:00
Andrey A. Chernov 9d8c91b749 If uptime < 1 min print in in secs otherwise we got confusing message
"up 1 user"
1997-10-13 15:17:03 +00:00
Andrey A. Chernov 7860b557b8 Document newly added -d option and fix usage string 1997-09-12 02:26:12 +00:00
Andrey A. Chernov 1bb32253c5 The "-d" option dumps out the entire process list on a per controlling
tty basis, instead of just the top level process.
Submitted by: terry
1997-09-12 02:22:21 +00:00
Philippe Charnier 57bd99e61c Revert some casts I introduced.
Requested by: Bruce.
1997-08-26 06:59:34 +00:00
Philippe Charnier 90389da95b Typo in usage(). Err -> errx when testing allocations. 1997-08-25 06:42:19 +00:00
Warner Losh 1c8af87873 compare return value from getopt against -1 rather than EOF, per the final
posix standard on the topic.
1997-03-29 04:34:07 +00:00
Kazutaka YOKOTA 6d7977a7cc Made sure the string formated by strftime() is properly
null-terminated.

Should go to RELENG_2_1 and RELENG_2_2.

Reviewed by guido@freebsd.org.
1997-03-07 10:54:19 +00:00
Peter Wemm c115df18cd Revert $FreeBSD$ to $Id$ 1997-02-22 19:58:13 +00:00
Daniel O'Callaghan 70498d5a53 Reduce the command field width by one when idle time is > 9 days, to
eliminate unsightly blank line.

Possibly a 2.2 candidate.
1997-02-11 10:49:25 +00:00
Wolfram Schneider da1ff3cb8a Sort cross references. 1997-01-15 23:25:55 +00:00
Jordan K. Hubbard 1130b656e5 Make the long-awaited change from $Id$ to $FreeBSD$
This will make a number of things easier in the future, as well as (finally!)
avoiding the Id-smashing problem which has plagued developers for so long.

Boy, I'm glad we're not using sup anymore.  This update would have been
insane otherwise.
1997-01-14 07:20:47 +00:00
Wolfram Schneider 13608f6661 comma typos 1996-12-23 23:09:55 +00:00
Andrey A. Chernov d916216786 Increase username field to reflect utmp changes 1996-12-05 17:00:16 +00:00
Andrey A. Chernov c54481c15a Do not print herror message, if w -n gethostname failed to be 100%
compatible with any program
Suggested by: peter
1996-06-17 20:07:44 +00:00
Andrey A. Chernov 1694c5cb7a Fix xterm/screen/(any program using just :xxx form) compatibility 1996-06-17 19:23:38 +00:00
Andrey A. Chernov 0fd06e5d7c Don't try convert "-" to numeric form for -n option 1996-06-17 18:35:16 +00:00
Andrey A. Chernov 66b12529e6 Fix w -n to really show numeric addresses, close PR 402
Partially submitted by: henrich@msu.edu (Charles Henrich)
1996-06-17 15:46:25 +00:00
Paul Traina 66e5b18f29 Drop privileges if not using standard namelist or kernel file.
Submitted by:	smpatel (Sujal Patel)
1996-05-30 02:20:10 +00:00
Andrey A. Chernov d1b2ad1a54 Change locale to LC_ALL, there is no bitmask 1995-10-26 11:03:08 +00:00