aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilippe Charnier <charnier@FreeBSD.org>1997-06-19 14:28:32 +0000
committerPhilippe Charnier <charnier@FreeBSD.org>1997-06-19 14:28:32 +0000
commita2bfcdfd767b1f22a87663d8065ab64b3e965cf0 (patch)
tree68021b48cb73a0da51fe2414f01ba65f33d64e3b
parent904058d0ad70f4d3b30b85df9269a39cc030c7d7 (diff)
downloadsrc-a2bfcdfd767b1f22a87663d8065ab64b3e965cf0.tar.gz
src-a2bfcdfd767b1f22a87663d8065ab64b3e965cf0.zip
Use err(3).
Notes
Notes: svn path=/head/; revision=26737
-rw-r--r--sbin/shutdown/shutdown.c34
1 files changed, 13 insertions, 21 deletions
diff --git a/sbin/shutdown/shutdown.c b/sbin/shutdown/shutdown.c
index 8a66ab9003dc..f892fcf4933a 100644
--- a/sbin/shutdown/shutdown.c
+++ b/sbin/shutdown/shutdown.c
@@ -29,6 +29,8 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
+ *
+ * $Id$
*/
#ifndef lint
@@ -55,6 +57,7 @@ static char sccsid[] = "@(#)shutdown.c 8.2 (Berkeley) 2/16/94";
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <err.h>
#include "pathnames.h"
@@ -104,10 +107,8 @@ main(argc, argv)
int arglen, ch, len, readstdin;
#ifndef DEBUG
- if (geteuid()) {
- (void)fprintf(stderr, "shutdown: NOT super-user\n");
- exit(1);
- }
+ if (geteuid())
+ errx(1, "NOT super-user");
#endif
nosync = NULL;
readstdin = 0;
@@ -139,8 +140,7 @@ main(argc, argv)
usage();
if (doreboot && dohalt) {
- (void)fprintf(stderr,
- "shutdown: incompatible switches -h and -r.\n");
+ warnx("incompatible switches -h and -r.");
usage();
}
getoffset(*argv++);
@@ -191,14 +191,10 @@ main(argc, argv)
int forkpid;
forkpid = fork();
- if (forkpid == -1) {
- perror("shutdown: fork");
- exit(1);
- }
- if (forkpid) {
- (void)printf("shutdown: [pid %d]\n", forkpid);
- exit(0);
- }
+ if (forkpid == -1)
+ err(1, "fork");
+ if (forkpid)
+ errx(0, "[pid %d]", forkpid);
}
#endif
openlog("shutdown", LOG_CONS, LOG_AUTH);
@@ -406,11 +402,8 @@ getoffset(timearg)
lt->tm_sec = 0;
if ((shuttime = mktime(lt)) == -1)
badtime();
- if ((offset = shuttime - now) < 0) {
- (void)fprintf(stderr,
- "shutdown: that time is already past.\n");
- exit(1);
- }
+ if ((offset = shuttime - now) < 0)
+ errx(1, "that time is already past.");
break;
default:
badtime();
@@ -451,8 +444,7 @@ finish(signo)
void
badtime()
{
- (void)fprintf(stderr, "shutdown: bad time format.\n");
- exit(1);
+ errx(1, "bad time format.");
}
void