summaryrefslogtreecommitdiffstats
path: root/sbin
diff options
context:
space:
mode:
authorcharnier <charnier@FreeBSD.org>1997-06-19 14:28:32 +0000
committercharnier <charnier@FreeBSD.org>1997-06-19 14:28:32 +0000
commiteb50166664e3f81278c5519e75c222688225d693 (patch)
treed04e40ebed56f8f9e945dc911f25699e642589ec /sbin
parent49bea635234660b15ec2cdfb01e3eabb0d585cd3 (diff)
downloadFreeBSD-src-eb50166664e3f81278c5519e75c222688225d693.zip
FreeBSD-src-eb50166664e3f81278c5519e75c222688225d693.tar.gz
Use err(3).
Diffstat (limited to 'sbin')
-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 8a66ab9..f892fcf 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
OpenPOWER on IntegriCloud