summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Shalayeff <mickey@cvs.openbsd.org>2006-05-10 17:36:13 +0000
committerMichael Shalayeff <mickey@cvs.openbsd.org>2006-05-10 17:36:13 +0000
commit787b2a2682f76d628dbe673665840a52ea0e3b74 (patch)
tree8fe2b13d641e780d9fc2464bb7d67c33b88baf02
parent9ba81b537a58f055aa838230dfca97a7a5e1e8a7 (diff)
fail zzz w/ a reasonable error msg if apmd is not running; found by deraadt@
-rw-r--r--usr.sbin/apm/apm.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/usr.sbin/apm/apm.c b/usr.sbin/apm/apm.c
index 26c2eda9cc6..1a3452e9b85 100644
--- a/usr.sbin/apm/apm.c
+++ b/usr.sbin/apm/apm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: apm.c,v 1.21 2006/04/12 19:41:08 deraadt Exp $ */
+/* $OpenBSD: apm.c,v 1.22 2006/05/10 17:36:12 mickey Exp $ */
/*
* Copyright (c) 1996 John T. Kohl
@@ -226,8 +226,12 @@ main(int argc, char *argv[])
fd = open_socket(sockname);
- if (!strcmp(__progname, "zzz"))
- return (do_zzz(fd, action));
+ if (!strcmp(__progname, "zzz")) {
+ if (fd < 0)
+ err(1, "cannot connect to apmd");
+ else
+ return (do_zzz(fd, action));
+ }
bzero(&reply, sizeof reply);
reply.batterystate.battery_state = APM_BATT_UNKNOWN;