Module Name: src Committed By: dholland Date: Sat Jun 28 17:32:27 UTC 2014
Modified Files: src/bin/ps: ps.c Log Message: Don't print junk errnos. Avoids: % ps -tfoo ps: /dev/ttyfoo: Undefined error: 0 Exit 1 To generate a diff of this commit: cvs rdiff -u -r1.81 -r1.82 src/bin/ps/ps.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/bin/ps/ps.c diff -u src/bin/ps/ps.c:1.81 src/bin/ps/ps.c:1.82 --- src/bin/ps/ps.c:1.81 Sun Apr 20 23:31:40 2014 +++ src/bin/ps/ps.c Sat Jun 28 17:32:27 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: ps.c,v 1.81 2014/04/20 23:31:40 dholland Exp $ */ +/* $NetBSD: ps.c,v 1.82 2014/06/28 17:32:27 dholland Exp $ */ /* * Copyright (c) 2000-2008 The NetBSD Foundation, Inc. @@ -68,7 +68,7 @@ __COPYRIGHT("@(#) Copyright (c) 1990, 19 #if 0 static char sccsid[] = "@(#)ps.c 8.4 (Berkeley) 4/2/94"; #else -__RCSID("$NetBSD: ps.c,v 1.81 2014/04/20 23:31:40 dholland Exp $"); +__RCSID("$NetBSD: ps.c,v 1.82 2014/06/28 17:32:27 dholland Exp $"); #endif #endif /* not lint */ @@ -175,8 +175,11 @@ ttyname2dev(const char *ttname, int *xfl ttypath = ttname; *what = KERN_PROC_TTY; if (stat(ttypath, &sb) == -1) { - devmajor_t pts = getdevmajor("pts", S_IFCHR); + devmajor_t pts; + int serrno; + serrno = errno; + pts = getdevmajor("pts", S_IFCHR); if (pts != NODEVMAJOR && strncmp(ttname, "pts/", 4) == 0) { int ptsminor = atoi(ttname + 4); @@ -184,6 +187,7 @@ ttyname2dev(const char *ttname, int *xfl if (strcmp(pathbuf, ttname) == 0 && ptsminor >= 0) return makedev(pts, ptsminor); } + errno = serrno; err(1, "%s", ttypath); } if (!S_ISCHR(sb.st_mode))