Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 11 Dec 2011 11:42:44 +0000 (UTC)
From:      Ed Schouten <ed@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r228408 - head/sbin/reboot
Message-ID:  <201112111142.pBBBgiO1051036@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ed
Date: Sun Dec 11 11:42:44 2011
New Revision: 228408
URL: http://svn.freebsd.org/changeset/base/228408

Log:
  Let reboot(8) use getprogname() to compare the program name.
  
  While there, mark the global variable dohalt static, as reboot(8) only
  consists of a single C file.

Modified:
  head/sbin/reboot/reboot.c

Modified: head/sbin/reboot/reboot.c
==============================================================================
--- head/sbin/reboot/reboot.c	Sun Dec 11 11:38:50 2011	(r228407)
+++ head/sbin/reboot/reboot.c	Sun Dec 11 11:42:44 2011	(r228408)
@@ -60,7 +60,7 @@ __FBSDID("$FreeBSD$");
 static void usage(void);
 static u_int get_pageins(void);
 
-int dohalt;
+static int dohalt;
 
 int
 main(int argc, char *argv[])
@@ -69,9 +69,9 @@ main(int argc, char *argv[])
 	const struct passwd *pw;
 	int ch, howto, i, fd, lflag, nflag, qflag, sverrno;
 	u_int pageins;
-	const char *p, *user, *kernel = NULL;
+	const char *user, *kernel = NULL;
 
-	if (strstr((p = rindex(*argv, '/')) ? p + 1 : *argv, "halt")) {
+	if (strcmp(getprogname(), "halt") == 0) {
 		dohalt = 1;
 		howto = RB_HALT;
 	} else



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201112111142.pBBBgiO1051036>