History log of /freebsd-9.3-release/usr.bin/w/w.c
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 267654 19-Jun-2014 gjb

Copy stable/9 to releng/9.3 as part of the 9.3-RELEASE cycle.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation

# 247516 28-Feb-2013 jhb

MFC 245610,245633,245635:
Include the thread name along with the command name when displaying the
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.


# 243293 19-Nov-2012 emaste

MFC r241484: Use CLOCK_UPTIME to get the uptime.


# 225736 22-Sep-2011 kensmith

Copy head to stable/9 as part of 9.0-RELEASE release cycle.

Approved by: re (implicit)


# 223786 05-Jul-2011 ed

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.


# 216370 11-Dec-2010 joel

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


# 203688 08-Feb-2010 brucec

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


# 202199 13-Jan-2010 ed

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.


# 201611 05-Jan-2010 dwmalone

Shuffle parens to avoid type-punning warning.


# 200462 13-Dec-2009 delphij

Revert most part of 200420 as requested, as more review and polish is
needed.


# 200420 11-Dec-2009 delphij

Remove unneeded header includes from usr.bin/ except contributed code.

Tested with: make universe


# 200172 05-Dec-2009 ed

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.


# 199655 22-Nov-2009 ume

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


# 196652 30-Aug-2009 ume

Fix the problem that the entry broke into two lines with multi-byte
AM/PM format.

Reported by: takawata


# 158444 11-May-2006 phk

Use sysctlbyname


# 151417 17-Oct-2005 andre

Obtain true uptime through clock_gettime(CLOCK_MONOTONIC, struct *timespec)
instead of subtracting 'bootime' from 'now'.

Sponsored by: TCP/IP Optimization Fundraise 2005


# 146983 04-Jun-2005 gad

Use the ki_udata field that was recently-added to kinfo_proc, instead of
stealing ki_spare[0] to hold a pointer.


# 119854 07-Sep-2003 charnier

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.


# 116998 28-Jun-2003 peter

utmp.ut_time is not a time_t, do not pass a pointer to it to pr_attime().


# 102300 23-Aug-2002 seanc

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


# 97981 06-Jun-2002 jmallett

ANSI style function declarations.


# 92922 21-Mar-2002 imp

remove __P


# 91837 07-Mar-2002 obrien

Back out part of rev 1.51. The lesser impact fix is to just remove
the unused global var.


# 87674 11-Dec-2001 markm

WARNS=2 fix, use __FBSDID() and sort includes.

WARNS=2 not added to Makefile as it is to become default.


# 84768 10-Oct-2001 bde

Compensate for "Compensate for header dethreading" by backing it out.


# 83815 22-Sep-2001 cjc

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


# 80407 26-Jul-2001 brian

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).


# 77367 28-May-2001 phk

Call kvm_close() before exit for consistency.

PR: 24654
Submitted by: Daniel Hemmerich zartik@yahoo.com


# 77212 25-May-2001 tmm

Fix the error buffer passed to kvm_openfiles to have a correct length
of _POSIX2_LINE_MAX.

MFC after: 1 week


# 76169 01-May-2001 markm

Compensate for header dethreading.


# 73385 03-Mar-2001 ache

Preserve comma as separator when it is not equal to radix character


# 73368 02-Mar-2001 ache

Don't use "," as load avg. separator because it can be precision point in some
locales, so leads to confusion


# 73365 02-Mar-2001 ache

Use AM/PM time only when available in locale


# 70272 22-Dec-2000 brian

Hostnames are case-insensitive


# 70242 20-Dec-2000 brian

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


# 69896 12-Dec-2000 mckusick

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.


# 53279 17-Nov-1999 peter

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)


# 50477 27-Aug-1999 peter

$Id$ -> $FreeBSD$


# 49177 28-Jul-1999 green

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


# 48566 04-Jul-1999 billf

Clean up some ambiguous nested if/elses.


# 45946 22-Apr-1999 ache

fix -n with 16-chars hostnames, modified patch from PR

PR: 11286
Submitted by: Hans Huebner <hans@chaosradio.berlin.ccc.de>


# 45201 31-Mar-1999 brian

Get things right for tty names of length UT_LINESIZE.
Cosmetic: Don't shadow the `p' variable.
Remove two unused variables.
PR: 3638


# 42481 10-Jan-1999 peter

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.


# 42055 24-Dec-1998 dillon

No __profname bozoness, no strstr() bozoness... test argv[0] against
"uptime" the right way. Sheesh.


# 42050 24-Dec-1998 steve

Since argv is in scope, use argv[0] instead of __progname.

Suggested by: bde


# 41022 08-Nov-1998 steve

Do a better job of determining if we were called as uptime(1).

PR: 8593


# 36793 09-Jun-1998 imp

Remove unused strvisx.


# 36276 21-May-1998 jkoshy

Cosmetic fix. Compute header field widths from UT_{HOST,LINE,NAME}SIZE
instead of hardcoding header line.

PR: 6325


# 36031 14-May-1998 jkoshy

Allow `w' to treat a corrupted "utmp" as a non fatal error.

PR: bin/2832


# 35309 19-Apr-1998 phk

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>


# 30389 13-Oct-1997 ache

If uptime < 1 min print in in secs otherwise we got confusing message
"up 1 user"


# 29311 12-Sep-1997 ache

Document newly added -d option and fix usage string


# 29310 12-Sep-1997 ache

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


# 28694 25-Aug-1997 charnier

Typo in usage(). Err -> errx when testing allocations.


# 24360 29-Mar-1997 imp

compare return value from getopt against -1 rather than EOF, per the final
posix standard on the topic.


# 23493 07-Mar-1997 yokota

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.


# 22558 11-Feb-1997 danny

Reduce the command field width by one when idle time is > 9 days, to
eliminate unsightly blank line.

Possibly a 2.2 candidate.


# 20155 05-Dec-1996 ache

Increase username field to reflect utmp changes


# 16455 17-Jun-1996 ache

Do not print herror message, if w -n gethostname failed to be 100%
compatible with any program
Suggested by: peter


# 16446 17-Jun-1996 ache

Fix xterm/screen/(any program using just :xxx form) compatibility


# 16443 17-Jun-1996 ache

Don't try convert "-" to numeric form for -n option


# 16436 17-Jun-1996 ache

Fix w -n to really show numeric addresses, close PR 402
Partially submitted by: henrich@msu.edu (Charles Henrich)


# 15993 30-May-1996 pst

Drop privileges if not using standard namelist or kernel file.
Submitted by: smpatel (Sujal Patel)


# 11811 26-Oct-1995 ache

Change locale to LC_ALL, there is no bitmask


# 11755 24-Oct-1995 ache

Add setlocale LC_TIME|LC_CTYPE


# 10553 03-Sep-1995 peter

Increase the tty column width from 2 to 3 characters.

This gives us more room to breath with tty names, especially with drivers
that support large numbers of ports.. eg: specialix and digiboard.

This does not actually change the current tty names, it just allows room
for reporting more characters if the drivers use them.


# 9987 07-Aug-1995 wollman

Delete bogus referneces to timezone code internal header file `tzfile.h',
which is no longer bogusly installed in /usr/include.


# 9573 18-Jul-1995 peter

When 'w' finds an IP address in the ut_host field, it attempts to do
a gethostbyname() on it. That can take a long time... (especially
if the reason the IP address is in there in the first place is because
login/rlogind/telnetd couldn't find it either....)
This patch reduces the gethostbyaddr lookup time to 2 seconds, the idea being
that if the local nameserver knows the answer, it'll answer within that time,
otherwise we dont care... :-)
This change doesn't do anything about whether or not w should do this in the
first place, but at least it will make the current behavior less painful.
Reviewed by: David Greenman


# 9555 17-Jul-1995 peter

Fix the 'w' command so that the -h option correctly supresses the heading
as per the manual page. Closes PR578.
Reviewed by:
Submitted by: Kenneth D. Merry
Obtained from:


# 8874 30-May-1995 rgrimes

Remove trailing whitespace.


# 8555 16-May-1995 dg

If an ut_host field in an utmp entry contains a ':' (e.g. for an xterm session)
w doesn't handle the non-'\0' terminated char arrays in struct utmp properly.

Submitted by: jarle@idt.unit.no


# 6542 18-Feb-1995 smace

Correct the grammar for the label of the number of users.
It is plural when zero and >1 users are logged in.


# 3138 26-Sep-1994 ache

idle time == 0 printed now as "-" like in good old BSD
skip cua* 3 chars as tty* 3 lchars


# 1591 27-May-1994 rgrimes

This commit was generated by cvs2svn to compensate for changes in r1590,
which included commits to RCS files with non-trunk default branches.


# 1590 27-May-1994 rgrimes

BSD 4.4 Lite Usr.bin Sources