usage(gzip_usage);
strncpy(ifname, *argv, MAX_PATH_LEN);
- /* Open input fille */
+ /* Open input file */
inFileNum = open(ifname, O_RDONLY);
- if (inFileNum < 0) {
- perror(ifname);
- exit(WARNING);
- }
+ if (inFileNum < 0)
+ perror_msg_and_die("%s", ifname);
/* Get the time stamp on the input file. */
- result = stat(ifname, &statBuf);
- if (result < 0) {
- perror(ifname);
- exit(WARNING);
- }
+ if (stat(ifname, &statBuf) < 0)
+ perror_msg_and_die("%s", ifname);
time_stamp = statBuf.st_ctime;
ifile_size = statBuf.st_size;
}
#else
outFileNum = open(ofname, O_RDWR | O_CREAT | O_EXCL);
#endif
- if (outFileNum < 0) {
- perror(ofname);
- exit(WARNING);
- }
+ if (outFileNum < 0)
+ perror_msg_and_die("%s", ofname);
SET_BINARY_MODE(outFileNum);
/* Set permissions on the file */
fchmod(outFileNum, statBuf.st_mode);
else
delFileName = ofname;
- if (unlink(delFileName) < 0) {
- perror(delFileName);
- exit(EXIT_FAILURE);
- }
+ if (unlink(delFileName) < 0)
+ perror_msg_and_die("%s", delFileName);
}
return(exit_code);
if (argc == 1) {
/* deallocate all unused consoles */
- if (ioctl(fd, VT_DISALLOCATE, 0)) {
- perror("VT_DISALLOCATE");
- return EXIT_FAILURE;
- }
+ if (ioctl(fd, VT_DISALLOCATE, 0))
+ perror_msg_and_die("VT_DISALLOCATE");
} else {
for (i = 1; i < argc; i++) {
num = atoi(argv[i]);
error_msg("0: illegal VT number\n");
else if (num == 1)
error_msg("VT 1 cannot be deallocated\n");
- else if (ioctl(fd, VT_DISALLOCATE, num)) {
- perror("VT_DISALLOCATE");
- error_msg_and_die("could not deallocate console %d\n", num);
- }
+ else if (ioctl(fd, VT_DISALLOCATE, num))
+ perror_msg_and_die("VT_DISALLOCATE");
}
}
int is_unicode;
if (fstat(fileno(fp), &stbuf))
- perror("Cannot stat map file"), exit(1);
+ perror_msg_and_die("Cannot stat map file");
/* first try a UTF screen-map: either ASCII (no restriction) or binary (regular file) */
if (!
if (parse_failed) {
if (-1 == fseek(fp, 0, SEEK_SET)) {
if (errno == ESPIPE)
- error_msg("16bit screen-map MUST be a regular file.\n"),
- exit(1);
+ error_msg_and_die("16bit screen-map MUST be a regular file.\n");
else
- perror("fseek failed reading binary 16bit screen-map"),
- exit(1);
+ perror_msg_and_die("fseek failed reading binary 16bit screen-map");
}
if (fread(wbuf, sizeof(unicode) * E_TABSZ, 1, fp) != 1)
- perror("Cannot read [new] map from file"), exit(1);
+ perror_msg_and_die("Cannot read [new] map from file");
#if 0
else
error_msg("Input screen-map is binary.\n");
/* same if it was binary, ie. if parse_failed */
if (parse_failed || is_unicode) {
if (ioctl(fd, PIO_UNISCRNMAP, wbuf))
- perror("PIO_UNISCRNMAP ioctl"), exit(1);
+ perror_msg_and_die("PIO_UNISCRNMAP ioctl");
else
return 0;
}
error_msg("Assuming 8bit screen-map - MUST be a regular file.\n"),
exit(1);
else
- perror("fseek failed assuming 8bit screen-map"), exit(1);
+ perror_msg_and_die("fseek failed assuming 8bit screen-map");
}
/* ... and try an old 8-bit screen-map */
if (-1 == fseek(fp, 0, SEEK_SET)) {
if (errno == ESPIPE)
/* should not - it succedeed above */
- error_msg("fseek() returned ESPIPE !\n"),
- exit(1);
+ error_msg_and_die("fseek() returned ESPIPE !\n");
else
- perror("fseek for binary 8bit screen-map"), exit(1);
+ perror_msg_and_die("fseek for binary 8bit screen-map");
}
if (fread(buf, E_TABSZ, 1, fp) != 1)
- perror("Cannot read [old] map from file"), exit(1);
+ perror_msg_and_die("Cannot read [old] map from file");
#if 0
else
error_msg("Input screen-map is binary.\n");
}
if (ioctl(fd, PIO_SCRNMAP, buf))
- perror("PIO_SCRNMAP ioctl"), exit(1);
+ perror_msg_and_die("PIO_SCRNMAP ioctl");
else
return 0;
}
if (NULL == fgets(buffer, sizeof(buffer), fp)) {
if (feof(fp))
break;
- else {
- perror("uni_screen_map_read_ascii() can't read line");
- exit(2);
- }
+ else
+ perror_msg_and_die("uni_screen_map_read_ascii() can't read line");
}
/* get "charset-relative charcode", stripping leading spaces */
int is_old_map = 0;
if (ioctl(fd, GIO_UNISCRNMAP, xbuf)) {
- perror("GIO_UNISCRNMAP ioctl error");
+ perror_msg("GIO_UNISCRNMAP ioctl error");
#endif
- if (ioctl(fd, GIO_SCRNMAP, buf)) {
- perror("GIO_SCRNMAP ioctl error");
- exit(1);
- } else
+ if (ioctl(fd, GIO_SCRNMAP, buf))
+ perror_msg_and_die("GIO_SCRNMAP ioctl error");
+ else
is_old_map = 1;
#ifdef GIO_UNISCRNMAP
}
#ifdef GIO_UNISCRNMAP
if (is_old_map) {
#endif
- if (fwrite(buf, E_TABSZ, 1, fp) != 1) {
- perror("Error writing map to file");
- exit(1);
- }
+ if (fwrite(buf, E_TABSZ, 1, fp) != 1)
+ perror_msg_and_die("Error writing map to file");
#ifdef GIO_UNISCRNMAP
} else if (fwrite(xbuf, sizeof(unicode) * E_TABSZ, 1, fp) != 1) {
- perror("Error writing map to file");
- exit(1);
+ perror_msg_and_die("Error writing map to file");
}
#endif
}
if (argc < 1 || *argv[0] == '-')
usage(mkfifo_usage);
- if (mkfifo(*argv, mode) < 0) {
- perror("mkfifo");
- return EXIT_FAILURE;
- }
+ if (mkfifo(*argv, mode) < 0)
+ perror_msg_and_die("mkfifo");
return EXIT_SUCCESS;
}
mode |= perm;
if (mknod(argv[0], mode, dev) != 0)
- error_msg_and_die("%s: %s\n", argv[0], strerror(errno));
+ perror_msg_and_die("%s", argv[0]);
return EXIT_SUCCESS;
}
usage(sleep_usage);
}
- if (sleep(atoi(*(++argv))) != 0) {
- perror("sleep");
- return EXIT_FAILURE;
- }
+ if (sleep(atoi(*(++argv))) != 0)
+ perror_msg_and_die("sleep");
return EXIT_SUCCESS;
}
toprint = PRINT_SYSNAME;
if (uname(&name) == -1)
- perror("cannot get system name");
+ perror_msg("cannot get system name");
#if defined (HAVE_SYSINFO) && defined (SI_ARCHITECTURE)
if (sysinfo(SI_ARCHITECTURE, processor, sizeof(processor)) == -1)
- perror("cannot get processor type");
+ perror_msg("cannot get processor type");
}
#else
if (argc == 1) {
/* deallocate all unused consoles */
- if (ioctl(fd, VT_DISALLOCATE, 0)) {
- perror("VT_DISALLOCATE");
- return EXIT_FAILURE;
- }
+ if (ioctl(fd, VT_DISALLOCATE, 0))
+ perror_msg_and_die("VT_DISALLOCATE");
} else {
for (i = 1; i < argc; i++) {
num = atoi(argv[i]);
error_msg("0: illegal VT number\n");
else if (num == 1)
error_msg("VT 1 cannot be deallocated\n");
- else if (ioctl(fd, VT_DISALLOCATE, num)) {
- perror("VT_DISALLOCATE");
- error_msg_and_die("could not deallocate console %d\n", num);
- }
+ else if (ioctl(fd, VT_DISALLOCATE, num))
+ perror_msg_and_die("VT_DISALLOCATE");
}
}
}
if (cmd == 8) {
- n = klogctl(cmd, NULL, level);
- if (n < 0) {
- goto klogctl_error;
- }
+ if (klogctl(cmd, NULL, level) < 0)
+ perror_msg_and_die("klogctl");
return EXIT_SUCCESS;
}
if (bufsize < 4096)
bufsize = 4096;
buf = (char *) xmalloc(bufsize);
- n = klogctl(cmd, buf, bufsize);
- if (n < 0) {
- goto klogctl_error;
- }
+ if ((n = klogctl(cmd, buf, bufsize)) < 0)
+ perror_msg_and_die("klogctl");
lastc = '\n';
for (i = 0; i < n; i++) {
end:
usage(dmesg_usage);
return EXIT_FAILURE;
- klogctl_error:
- perror("klogctl");
- return EXIT_FAILURE;
}
#ifdef BB_FEATURE_CLEAN_UP
/* destroy command strings on exit */
- if (atexit(destroy_cmd_strs) == -1) {
- perror("sed");
- exit(1);
- }
+ if (atexit(destroy_cmd_strs) == -1)
+ perror_msg_and_die("atexit");
#endif
/* do normal option parsing */
#include <ctype.h>
#include <sys/ioctl.h>
-#define PERROR(ctx) do { perror(ctx); exit(1); } while(0)
-
#define DEFAULTFBDEV "/dev/fb0"
#define DEFAULTFBMODE "/etc/fb.modes"
char *p = buf;
if ((f = fopen(fn, "r")) == NULL)
- PERROR("readmode(fopen)");
+ perror_msg_and_die("readmode(fopen)");
while (!feof(f)) {
fgets(buf, sizeof(buf), f);
if ((p = strstr(buf, "mode ")) || (p = strstr(buf, "mode\t"))) {
}
if ((fh = open(fbdev, O_RDONLY)) < 0)
- PERROR("fbset(open)");
+ perror_msg_and_die("fbset(open)");
if (ioctl(fh, FBIOGET_VSCREENINFO, &var))
- PERROR("fbset(ioctl)");
+ perror_msg_and_die("fbset(ioctl)");
if (g_options & OPT_READMODE) {
if (!readmode(&var, modefile, mode)) {
error_msg("Unknown video mode `%s'\n", mode);
setmode(&var, &varset);
if (g_options & OPT_CHANGE)
if (ioctl(fh, FBIOPUT_VSCREENINFO, &var))
- PERROR("fbset(ioctl)");
+ perror_msg_and_die("fbset(ioctl)");
showmode(&var);
/* Don't close the file, as exiting will take care of that */
/* close(fh); */
extern int fdflush_main(int argc, char **argv)
{
- int value;
int fd;
if (argc <= 1 || **(++argv) == '-')
usage(fdflush_usage);
- fd = open(*argv, 0);
- if (fd < 0) {
- perror(*argv);
- return EXIT_FAILURE;
- }
+ if ((fd = open(*argv, 0)) < 0)
+ perror_msg_and_die("%s", *argv);
- value = ioctl(fd, FDFLUSH, 0);
- /* Don't bother closing. Exit does
- * that, so we can save a few bytes */
- /* close(fd); */
+ if (ioctl(fd, FDFLUSH, 0))
+ perror_msg_and_die("%s", *argv);
- if (value) {
- perror(*argv);
- return EXIT_FAILURE;
- }
return EXIT_SUCCESS;
}
strcat(execstr, cmd_to_be_executed);
strcat(execstr, file_to_act_on);
cmd_output = popen(execstr, "r");
- if (cmd_output == NULL) {
- perror("popen");
- exit(1);
- }
+ if (cmd_output == NULL)
+ perror_msg_and_die("popen");
/* harvest the output */
while ((output_line = get_line_from_file(cmd_output)) != NULL) {
usage(gzip_usage);
strncpy(ifname, *argv, MAX_PATH_LEN);
- /* Open input fille */
+ /* Open input file */
inFileNum = open(ifname, O_RDONLY);
- if (inFileNum < 0) {
- perror(ifname);
- exit(WARNING);
- }
+ if (inFileNum < 0)
+ perror_msg_and_die("%s", ifname);
/* Get the time stamp on the input file. */
- result = stat(ifname, &statBuf);
- if (result < 0) {
- perror(ifname);
- exit(WARNING);
- }
+ if (stat(ifname, &statBuf) < 0)
+ perror_msg_and_die("%s", ifname);
time_stamp = statBuf.st_ctime;
ifile_size = statBuf.st_size;
}
#else
outFileNum = open(ofname, O_RDWR | O_CREAT | O_EXCL);
#endif
- if (outFileNum < 0) {
- perror(ofname);
- exit(WARNING);
- }
+ if (outFileNum < 0)
+ perror_msg_and_die("%s", ofname);
SET_BINARY_MODE(outFileNum);
/* Set permissions on the file */
fchmod(outFileNum, statBuf.st_mode);
else
delFileName = ofname;
- if (unlink(delFileName) < 0) {
- perror(delFileName);
- exit(EXIT_FAILURE);
- }
+ if (unlink(delFileName) < 0)
+ perror_msg_and_die("%s", delFileName);
}
return(exit_code);
/* vi: set sw=4 ts=4: */
/*
- * $Id: hostname.c,v 1.16 2000/12/07 19:56:48 markw Exp $
+ * $Id: hostname.c,v 1.17 2000/12/22 01:48:07 kraai Exp $
* Mini hostname implementation for busybox
*
* Copyright (C) 1999 by Randolph Chung <tausq@debian.org>
if (!isfile) {
if (sethostname(s, strlen(s)) < 0) {
if (errno == EPERM)
- error_msg("you must be root to change the hostname\n");
+ error_msg_and_die("you must be root to change the hostname\n");
else
- perror("sethostname");
- exit(1);
+ perror_msg_and_die("sethostname");
}
} else {
f = xfopen(s, "r");
fclose(f);
if (buf[strlen(buf) - 1] == '\n')
buf[strlen(buf) - 1] = 0;
- if (sethostname(buf, strlen(buf)) < 0) {
- perror("sethostname");
- exit(1);
- }
+ if (sethostname(buf, strlen(buf)) < 0)
+ perror_msg_and_die("sethostname");
}
}
#ifndef MODUTILS_MODULE_H
#define MODUTILS_MODULE_H 1
-#ident "$Id: insmod.c,v 1.33 2000/12/18 03:57:16 kraai Exp $"
+#ident "$Id: insmod.c,v 1.34 2000/12/22 01:48:07 kraai Exp $"
/* This file contains the structures used by the 2.0 and 2.1 kernels.
We do not use the kernel headers directly because we do not wish
#ifndef MODUTILS_OBJ_H
#define MODUTILS_OBJ_H 1
-#ident "$Id: insmod.c,v 1.33 2000/12/18 03:57:16 kraai Exp $"
+#ident "$Id: insmod.c,v 1.34 2000/12/22 01:48:07 kraai Exp $"
/* The relocatable object is manipulated using elfin types. */
memcpy(m_filename, *argv, strlen(*argv));
- if ((f = obj_load(fp)) == NULL) {
- perror("Could not load the module\n");
- return EXIT_FAILURE;
- }
+ if ((f = obj_load(fp)) == NULL)
+ perror_msg_and_die("Could not load the module");
if (get_modinfo_value(f, "kernel_version") == NULL)
m_has_modinfo = 0;
/* Make this job the foreground job */
/* suppress messages when run from /linuxrc mag@sysgo.de */
if (tcsetpgrp(0, job->pgrp) && errno != ENOTTY)
- perror("tcsetpgrp");
+ perror_msg("tcsetpgrp");
child->family->job_list->fg = job;
}
}
if (childpid == -1 && errno != ECHILD)
- perror("waitpid");
+ perror_msg("waitpid");
}
/* squirrel != NULL means we squirrel away copies of stdin, stdout,
/* move the new process group into the foreground */
/* suppress messages when run from /linuxrc mag@sysgo.de */
if (tcsetpgrp(0, newjob->pgrp) && errno != ENOTTY)
- perror("tcsetpgrp");
+ perror_msg("tcsetpgrp");
}
}
/* move the shell to the foreground */
/* suppress messages when run from /linuxrc mag@sysgo.de */
if (tcsetpgrp(0, getpid()) && errno != ENOTTY)
- perror("tcsetpgrp");
+ perror_msg("tcsetpgrp");
}
}
}
/* return controlling TTY back to parent process group before exiting */
if (tcsetpgrp(0, parent_pgrp))
- perror("tcsetpgrp");
+ perror_msg("tcsetpgrp");
/* return exit status if called with "-c" */
if (input == NULL && WIFEXITED(status))
int is_unicode;
if (fstat(fileno(fp), &stbuf))
- perror("Cannot stat map file"), exit(1);
+ perror_msg_and_die("Cannot stat map file");
/* first try a UTF screen-map: either ASCII (no restriction) or binary (regular file) */
if (!
if (parse_failed) {
if (-1 == fseek(fp, 0, SEEK_SET)) {
if (errno == ESPIPE)
- error_msg("16bit screen-map MUST be a regular file.\n"),
- exit(1);
+ error_msg_and_die("16bit screen-map MUST be a regular file.\n");
else
- perror("fseek failed reading binary 16bit screen-map"),
- exit(1);
+ perror_msg_and_die("fseek failed reading binary 16bit screen-map");
}
if (fread(wbuf, sizeof(unicode) * E_TABSZ, 1, fp) != 1)
- perror("Cannot read [new] map from file"), exit(1);
+ perror_msg_and_die("Cannot read [new] map from file");
#if 0
else
error_msg("Input screen-map is binary.\n");
/* same if it was binary, ie. if parse_failed */
if (parse_failed || is_unicode) {
if (ioctl(fd, PIO_UNISCRNMAP, wbuf))
- perror("PIO_UNISCRNMAP ioctl"), exit(1);
+ perror_msg_and_die("PIO_UNISCRNMAP ioctl");
else
return 0;
}
error_msg("Assuming 8bit screen-map - MUST be a regular file.\n"),
exit(1);
else
- perror("fseek failed assuming 8bit screen-map"), exit(1);
+ perror_msg_and_die("fseek failed assuming 8bit screen-map");
}
/* ... and try an old 8-bit screen-map */
if (-1 == fseek(fp, 0, SEEK_SET)) {
if (errno == ESPIPE)
/* should not - it succedeed above */
- error_msg("fseek() returned ESPIPE !\n"),
- exit(1);
+ error_msg_and_die("fseek() returned ESPIPE !\n");
else
- perror("fseek for binary 8bit screen-map"), exit(1);
+ perror_msg_and_die("fseek for binary 8bit screen-map");
}
if (fread(buf, E_TABSZ, 1, fp) != 1)
- perror("Cannot read [old] map from file"), exit(1);
+ perror_msg_and_die("Cannot read [old] map from file");
#if 0
else
error_msg("Input screen-map is binary.\n");
}
if (ioctl(fd, PIO_SCRNMAP, buf))
- perror("PIO_SCRNMAP ioctl"), exit(1);
+ perror_msg_and_die("PIO_SCRNMAP ioctl");
else
return 0;
}
if (NULL == fgets(buffer, sizeof(buffer), fp)) {
if (feof(fp))
break;
- else {
- perror("uni_screen_map_read_ascii() can't read line");
- exit(2);
- }
+ else
+ perror_msg_and_die("uni_screen_map_read_ascii() can't read line");
}
/* get "charset-relative charcode", stripping leading spaces */
int is_old_map = 0;
if (ioctl(fd, GIO_UNISCRNMAP, xbuf)) {
- perror("GIO_UNISCRNMAP ioctl error");
+ perror_msg("GIO_UNISCRNMAP ioctl error");
#endif
- if (ioctl(fd, GIO_SCRNMAP, buf)) {
- perror("GIO_SCRNMAP ioctl error");
- exit(1);
- } else
+ if (ioctl(fd, GIO_SCRNMAP, buf))
+ perror_msg_and_die("GIO_SCRNMAP ioctl error");
+ else
is_old_map = 1;
#ifdef GIO_UNISCRNMAP
}
#ifdef GIO_UNISCRNMAP
if (is_old_map) {
#endif
- if (fwrite(buf, E_TABSZ, 1, fp) != 1) {
- perror("Error writing map to file");
- exit(1);
- }
+ if (fwrite(buf, E_TABSZ, 1, fp) != 1)
+ perror_msg_and_die("Error writing map to file");
#ifdef GIO_UNISCRNMAP
} else if (fwrite(xbuf, sizeof(unicode) * E_TABSZ, 1, fp) != 1) {
- perror("Error writing map to file");
- exit(1);
+ perror_msg_and_die("Error writing map to file");
}
#endif
else
op.mt_count = 1; /* One, not zero, right? */
- if ((fd = open(file, O_RDONLY, 0)) < 0) {
- perror(file);
- return EXIT_FAILURE;
- }
+ if ((fd = open(file, O_RDONLY, 0)) < 0)
+ perror_msg_and_die("%s", file);
- if (ioctl(fd, MTIOCTOP, &op) != 0) {
- perror(file);
- return EXIT_FAILURE;
- }
+ if (ioctl(fd, MTIOCTOP, &op) != 0)
+ perror_msg_and_die("%s", file);
return EXIT_SUCCESS;
}
}
if (argc < 1 || *argv[0] == '-')
usage(mkfifo_usage);
- if (mkfifo(*argv, mode) < 0) {
- perror("mkfifo");
- return EXIT_FAILURE;
- }
+ if (mkfifo(*argv, mode) < 0)
+ perror_msg_and_die("mkfifo");
return EXIT_SUCCESS;
}
int fd;
long size;
- fd = open(file, O_RDWR);
- if (fd < 0) {
- perror(file);
- exit(1);
- }
+ if ((fd = open(file, O_RDWR)) < 0)
+ perror_msg_and_die("%s", file);
if (ioctl(fd, BLKGETSIZE, &size) >= 0) {
close(fd);
return (size * 512);
mode |= perm;
if (mknod(argv[0], mode, dev) != 0)
- error_msg_and_die("%s: %s\n", argv[0], strerror(errno));
+ perror_msg_and_die("%s", argv[0]);
return EXIT_SUCCESS;
}
int fd;
long size;
- fd = open(file, O_RDONLY);
- if (fd < 0) {
- perror(file);
- exit(1);
- }
+ if ((fd = open(file, O_RDONLY)) < 0)
+ perror_msg_and_die("%s", file);
if (ioctl(fd, BLKGETSIZE, &size) >= 0) {
int sectors_per_page = pagesize / 512;
}
DEV = open(device_name, O_RDWR);
- if (DEV < 0 || fstat(DEV, &statbuf) < 0) {
- perror(device_name);
- return EXIT_FAILURE;
- }
+ if (DEV < 0 || fstat(DEV, &statbuf) < 0)
+ perror_msg_and_die("%s", device_name);
if (!S_ISBLK(statbuf.st_mode))
check = 0;
else if (statbuf.st_rdev == 0x0300 || statbuf.st_rdev == 0x0340)
#ifndef MODUTILS_MODULE_H
#define MODUTILS_MODULE_H 1
-#ident "$Id: insmod.c,v 1.33 2000/12/18 03:57:16 kraai Exp $"
+#ident "$Id: insmod.c,v 1.34 2000/12/22 01:48:07 kraai Exp $"
/* This file contains the structures used by the 2.0 and 2.1 kernels.
We do not use the kernel headers directly because we do not wish
#ifndef MODUTILS_OBJ_H
#define MODUTILS_OBJ_H 1
-#ident "$Id: insmod.c,v 1.33 2000/12/18 03:57:16 kraai Exp $"
+#ident "$Id: insmod.c,v 1.34 2000/12/22 01:48:07 kraai Exp $"
/* The relocatable object is manipulated using elfin types. */
memcpy(m_filename, *argv, strlen(*argv));
- if ((f = obj_load(fp)) == NULL) {
- perror("Could not load the module\n");
- return EXIT_FAILURE;
- }
+ if ((f = obj_load(fp)) == NULL)
+ perror_msg_and_die("Could not load the module");
if (get_modinfo_value(f, "kernel_version") == NULL)
m_has_modinfo = 0;
switch (**argv) {
case 'a':
/* Unload _all_ unused modules via NULL delete_module() call */
- if (delete_module(NULL)) {
- perror("rmmod");
- return EXIT_FAILURE;
- }
+ if (delete_module(NULL))
+ perror_msg_and_die("rmmod");
return EXIT_SUCCESS;
default:
usage(rmmod_usage);
while (argc-- > 0) {
if (delete_module(*argv) < 0) {
- perror(*argv);
+ perror_msg("%s", *argv);
ret = EXIT_FAILURE;
}
argv++;
}
endmntent(mountTable);
} else {
- perror(mtab_file);
+ perror_msg_and_die("%s", mtab_file);
}
return EXIT_SUCCESS;
}
else
op.mt_count = 1; /* One, not zero, right? */
- if ((fd = open(file, O_RDONLY, 0)) < 0) {
- perror(file);
- return EXIT_FAILURE;
- }
+ if ((fd = open(file, O_RDONLY, 0)) < 0)
+ perror_msg_and_die("%s", file);
- if (ioctl(fd, MTIOCTOP, &op) != 0) {
- perror(file);
- return EXIT_FAILURE;
- }
+ if (ioctl(fd, MTIOCTOP, &op) != 0)
+ perror_msg_and_die("%s", file);
return EXIT_SUCCESS;
}
/* Bummer. fall back on trying the /proc filesystem */
&& (mountTable = setmntent("/proc/mounts", "r")) == 0) {
#endif
- perror(mtab_file);
+ perror_msg("%s", mtab_file);
return;
}
}
endmntent(mountTable);
} else if (errno != EROFS)
- perror(mtab_file);
+ perror_msg("%s", mtab_file);
}
void write_mtab(char *blockDevice, char *directory,
struct mntent m;
if (mountTable == 0) {
- perror(mtab_file);
+ perror_msg("%s", mtab_file);
return;
}
if (mountTable) {
/* vi: set sw=4 ts=4: */
/*
- * $Id: hostname.c,v 1.16 2000/12/07 19:56:48 markw Exp $
+ * $Id: hostname.c,v 1.17 2000/12/22 01:48:07 kraai Exp $
* Mini hostname implementation for busybox
*
* Copyright (C) 1999 by Randolph Chung <tausq@debian.org>
if (!isfile) {
if (sethostname(s, strlen(s)) < 0) {
if (errno == EPERM)
- error_msg("you must be root to change the hostname\n");
+ error_msg_and_die("you must be root to change the hostname\n");
else
- perror("sethostname");
- exit(1);
+ perror_msg_and_die("sethostname");
}
} else {
f = xfopen(s, "r");
fclose(f);
if (buf[strlen(buf) - 1] == '\n')
buf[strlen(buf) - 1] = 0;
- if (sethostname(buf, strlen(buf)) < 0) {
- perror("sethostname");
- exit(1);
- }
+ if (sethostname(buf, strlen(buf)) < 0)
+ perror_msg_and_die("sethostname");
}
}
/* vi: set sw=4 ts=4: */
/*
- * $Id: ping.c,v 1.29 2000/12/18 03:57:16 kraai Exp $
+ * $Id: ping.c,v 1.30 2000/12/22 01:48:07 kraai Exp $
* Mini ping implementation for busybox
*
* Copyright (C) 1999 by Randolph Chung <tausq@debian.org>
int pingsock, c;
char packet[DEFDATALEN + MAXIPLEN + MAXICMPLEN];
- if ((pingsock = socket(AF_INET, SOCK_RAW, 1)) < 0) { /* 1 == ICMP */
- perror("ping: creating a raw socket");
- exit(1);
- }
+ if ((pingsock = socket(AF_INET, SOCK_RAW, 1)) < 0) /* 1 == ICMP */
+ perror_msg_and_die("creating a raw socket");
/* drop root privs if running setuid */
setuid(getuid());
c = sendto(pingsock, packet, sizeof(packet), 0,
(struct sockaddr *) &pingaddr, sizeof(struct sockaddr_in));
- if (c < 0 || c != sizeof(packet)) {
- if (c < 0)
- perror("ping: sendto");
- error_msg("write incomplete\n");
- exit(1);
- }
+ if (c < 0 || c != sizeof(packet))
+ perror_msg_and_die("sendto");
signal(SIGALRM, noresp);
alarm(5); /* give the host 5000ms to respond */
(struct sockaddr *) &from, &fromlen)) < 0) {
if (errno == EINTR)
continue;
- perror("ping: recvfrom");
+ perror_msg("recvfrom");
continue;
}
if (c >= 76) { /* ip + icmp */
* proto->p_proto to have the correct value for "icmp" */
if ((pingsock = socket(AF_INET, SOCK_RAW,
(proto ? proto->p_proto : 1))) < 0) { /* 1 == ICMP */
- if (errno == EPERM) {
- error_msg("permission denied. (are you root?)\n");
- } else {
- perror("ping: creating a raw socket");
- }
- exit(1);
+ if (errno == EPERM)
+ error_msg_and_die("permission denied. (are you root?)\n");
+ else
+ perror_msg_and_die("creating a raw socket");
}
/* drop root privs if running setuid */
(struct sockaddr *) &from, &fromlen)) < 0) {
if (errno == EINTR)
continue;
- perror("ping: recvfrom");
+ perror_msg("recvfrom");
continue;
}
unpack(packet, c, &from);
/* vi: set sw=4 ts=4: */
/*
- * $Id: ping.c,v 1.29 2000/12/18 03:57:16 kraai Exp $
+ * $Id: ping.c,v 1.30 2000/12/22 01:48:07 kraai Exp $
* Mini ping implementation for busybox
*
* Copyright (C) 1999 by Randolph Chung <tausq@debian.org>
int pingsock, c;
char packet[DEFDATALEN + MAXIPLEN + MAXICMPLEN];
- if ((pingsock = socket(AF_INET, SOCK_RAW, 1)) < 0) { /* 1 == ICMP */
- perror("ping: creating a raw socket");
- exit(1);
- }
+ if ((pingsock = socket(AF_INET, SOCK_RAW, 1)) < 0) /* 1 == ICMP */
+ perror_msg_and_die("creating a raw socket");
/* drop root privs if running setuid */
setuid(getuid());
c = sendto(pingsock, packet, sizeof(packet), 0,
(struct sockaddr *) &pingaddr, sizeof(struct sockaddr_in));
- if (c < 0 || c != sizeof(packet)) {
- if (c < 0)
- perror("ping: sendto");
- error_msg("write incomplete\n");
- exit(1);
- }
+ if (c < 0 || c != sizeof(packet))
+ perror_msg_and_die("sendto");
signal(SIGALRM, noresp);
alarm(5); /* give the host 5000ms to respond */
(struct sockaddr *) &from, &fromlen)) < 0) {
if (errno == EINTR)
continue;
- perror("ping: recvfrom");
+ perror_msg("recvfrom");
continue;
}
if (c >= 76) { /* ip + icmp */
* proto->p_proto to have the correct value for "icmp" */
if ((pingsock = socket(AF_INET, SOCK_RAW,
(proto ? proto->p_proto : 1))) < 0) { /* 1 == ICMP */
- if (errno == EPERM) {
- error_msg("permission denied. (are you root?)\n");
- } else {
- perror("ping: creating a raw socket");
- }
- exit(1);
+ if (errno == EPERM)
+ error_msg_and_die("permission denied. (are you root?)\n");
+ else
+ perror_msg_and_die("creating a raw socket");
}
/* drop root privs if running setuid */
(struct sockaddr *) &from, &fromlen)) < 0) {
if (errno == EINTR)
continue;
- perror("ping: recvfrom");
+ perror_msg("recvfrom");
continue;
}
unpack(packet, c, &from);
switch (**argv) {
case 'a':
/* Unload _all_ unused modules via NULL delete_module() call */
- if (delete_module(NULL)) {
- perror("rmmod");
- return EXIT_FAILURE;
- }
+ if (delete_module(NULL))
+ perror_msg_and_die("rmmod");
return EXIT_SUCCESS;
default:
usage(rmmod_usage);
while (argc-- > 0) {
if (delete_module(*argv) < 0) {
- perror(*argv);
+ perror_msg("%s", *argv);
ret = EXIT_FAILURE;
}
argv++;
if ((err = read(infile, buffer, num)) != num) {
if (err < 0)
- perror(progname);
+ perror_msg_and_die(progname);
else
- fprintf(stderr, "Unexpected end of input file!\n");
- exit(1);
+ error_msg_and_die("Unexpected end of input file!\n");
}
}
/* Open input file */
if (argc == 1)
infile = STDIN_FILENO;
- else if ((infile = open(argv[1], O_RDONLY)) < 0) {
- perror(progname);
- exit(1);
- }
+ else if ((infile = open(argv[1], O_RDONLY)) < 0)
+ perror_msg_and_die("%s", argv[1]);
/* Read magic ID and output filename */
myread(4);
strcat(buffer, ".cpio.gz");
if (infile == STDIN_FILENO)
outfile = STDOUT_FILENO;
- else if ((outfile = open(buffer, O_WRONLY | O_CREAT | O_TRUNC, 0644)) < 0) {
- perror(progname);
- exit(1);
- }
+ else if ((outfile = open(buffer, O_WRONLY | O_CREAT | O_TRUNC, 0644)) < 0)
+ perror_msg_and_die("%s", buffer);
/*
* Now search for the GZIP signature. This is rather awkward, but I don't
}
buffer[0] = GZ_MAGIC_1;
buffer[1] = GZ_MAGIC_2;
- if (write(outfile, buffer, 2) < 0) {
- perror(progname);
- exit(1);
- }
+ if (write(outfile, buffer, 2) < 0)
+ perror_msg_and_die("write");
/* Now simply copy the GZIP archive into the output file */
while ((len = read(infile, buffer, BUFSIZE)) > 0) {
- if (write(outfile, buffer, len) < 0) {
- perror(progname);
- exit(1);
- }
- }
- if (len < 0) {
- perror(progname);
- exit(1);
+ if (write(outfile, buffer, len) < 0)
+ perror_msg_and_die("write");
}
- close(outfile);
- close(infile);
- exit(0);
+ if (len < 0)
+ perror_msg_and_die("read");
+ return EXIT_SUCCESS;
}
#ifdef BB_FEATURE_CLEAN_UP
/* destroy command strings on exit */
- if (atexit(destroy_cmd_strs) == -1) {
- perror("sed");
- exit(1);
- }
+ if (atexit(destroy_cmd_strs) == -1)
+ perror_msg_and_die("atexit");
#endif
/* do normal option parsing */
/* Make this job the foreground job */
/* suppress messages when run from /linuxrc mag@sysgo.de */
if (tcsetpgrp(0, job->pgrp) && errno != ENOTTY)
- perror("tcsetpgrp");
+ perror_msg("tcsetpgrp");
child->family->job_list->fg = job;
}
}
if (childpid == -1 && errno != ECHILD)
- perror("waitpid");
+ perror_msg("waitpid");
}
/* squirrel != NULL means we squirrel away copies of stdin, stdout,
/* move the new process group into the foreground */
/* suppress messages when run from /linuxrc mag@sysgo.de */
if (tcsetpgrp(0, newjob->pgrp) && errno != ENOTTY)
- perror("tcsetpgrp");
+ perror_msg("tcsetpgrp");
}
}
/* move the shell to the foreground */
/* suppress messages when run from /linuxrc mag@sysgo.de */
if (tcsetpgrp(0, getpid()) && errno != ENOTTY)
- perror("tcsetpgrp");
+ perror_msg("tcsetpgrp");
}
}
}
/* return controlling TTY back to parent process group before exiting */
if (tcsetpgrp(0, parent_pgrp))
- perror("tcsetpgrp");
+ perror_msg("tcsetpgrp");
/* return exit status if called with "-c" */
if (input == NULL && WIFEXITED(status))
/* Make this job the foreground job */
/* suppress messages when run from /linuxrc mag@sysgo.de */
if (tcsetpgrp(0, job->pgrp) && errno != ENOTTY)
- perror("tcsetpgrp");
+ perror_msg("tcsetpgrp");
child->family->job_list->fg = job;
}
}
if (childpid == -1 && errno != ECHILD)
- perror("waitpid");
+ perror_msg("waitpid");
}
/* squirrel != NULL means we squirrel away copies of stdin, stdout,
/* move the new process group into the foreground */
/* suppress messages when run from /linuxrc mag@sysgo.de */
if (tcsetpgrp(0, newjob->pgrp) && errno != ENOTTY)
- perror("tcsetpgrp");
+ perror_msg("tcsetpgrp");
}
}
/* move the shell to the foreground */
/* suppress messages when run from /linuxrc mag@sysgo.de */
if (tcsetpgrp(0, getpid()) && errno != ENOTTY)
- perror("tcsetpgrp");
+ perror_msg("tcsetpgrp");
}
}
}
/* return controlling TTY back to parent process group before exiting */
if (tcsetpgrp(0, parent_pgrp))
- perror("tcsetpgrp");
+ perror_msg("tcsetpgrp");
/* return exit status if called with "-c" */
if (input == NULL && WIFEXITED(status))
usage(sleep_usage);
}
- if (sleep(atoi(*(++argv))) != 0) {
- perror("sleep");
- return EXIT_FAILURE;
- }
+ if (sleep(atoi(*(++argv))) != 0)
+ perror_msg_and_die("sleep");
return EXIT_SUCCESS;
}
else
status = swapoff(device);
- if (status != 0) {
- perror(applet_name);
- exit(EXIT_FAILURE);
- }
+ if (status != 0)
+ perror_msg_and_die(applet_name);
}
static void do_em_all()
struct mntent *m;
FILE *f = setmntent("/etc/fstab", "r");
- if (f == NULL) {
- perror("/etc/fstab");
- exit(FALSE);
- }
+ if (f == NULL)
+ perror_msg_and_die("/etc/fstab");
while ((m = getmntent(f)) != NULL) {
if (strcmp(m->mnt_type, MNTTYPE_SWAP)==0) {
swap_enable_disable(m->mnt_fsname);
if (status != 0) {
/* Don't bother retrying the umount on busy devices */
if (errno == EBUSY) {
- perror(mountpt);
+ perror_msg("%s", mountpt);
continue;
}
status = do_umount(mountpt, useMtab);
}
if (do_umount(*argv, useMtab) == TRUE)
return EXIT_SUCCESS;
- perror("umount");
- return EXIT_FAILURE;
+ perror_msg_and_die("%s", *argv);
}
toprint = PRINT_SYSNAME;
if (uname(&name) == -1)
- perror("cannot get system name");
+ perror_msg("cannot get system name");
#if defined (HAVE_SYSINFO) && defined (SI_ARCHITECTURE)
if (sysinfo(SI_ARCHITECTURE, processor, sizeof(processor)) == -1)
- perror("cannot get processor type");
+ perror_msg("cannot get processor type");
}
#else
}
if (cmd == 8) {
- n = klogctl(cmd, NULL, level);
- if (n < 0) {
- goto klogctl_error;
- }
+ if (klogctl(cmd, NULL, level) < 0)
+ perror_msg_and_die("klogctl");
return EXIT_SUCCESS;
}
if (bufsize < 4096)
bufsize = 4096;
buf = (char *) xmalloc(bufsize);
- n = klogctl(cmd, buf, bufsize);
- if (n < 0) {
- goto klogctl_error;
- }
+ if ((n = klogctl(cmd, buf, bufsize)) < 0)
+ perror_msg_and_die("klogctl");
lastc = '\n';
for (i = 0; i < n; i++) {
end:
usage(dmesg_usage);
return EXIT_FAILURE;
- klogctl_error:
- perror("klogctl");
- return EXIT_FAILURE;
}
#include <ctype.h>
#include <sys/ioctl.h>
-#define PERROR(ctx) do { perror(ctx); exit(1); } while(0)
-
#define DEFAULTFBDEV "/dev/fb0"
#define DEFAULTFBMODE "/etc/fb.modes"
char *p = buf;
if ((f = fopen(fn, "r")) == NULL)
- PERROR("readmode(fopen)");
+ perror_msg_and_die("readmode(fopen)");
while (!feof(f)) {
fgets(buf, sizeof(buf), f);
if ((p = strstr(buf, "mode ")) || (p = strstr(buf, "mode\t"))) {
}
if ((fh = open(fbdev, O_RDONLY)) < 0)
- PERROR("fbset(open)");
+ perror_msg_and_die("fbset(open)");
if (ioctl(fh, FBIOGET_VSCREENINFO, &var))
- PERROR("fbset(ioctl)");
+ perror_msg_and_die("fbset(ioctl)");
if (g_options & OPT_READMODE) {
if (!readmode(&var, modefile, mode)) {
error_msg("Unknown video mode `%s'\n", mode);
setmode(&var, &varset);
if (g_options & OPT_CHANGE)
if (ioctl(fh, FBIOPUT_VSCREENINFO, &var))
- PERROR("fbset(ioctl)");
+ perror_msg_and_die("fbset(ioctl)");
showmode(&var);
/* Don't close the file, as exiting will take care of that */
/* close(fh); */
extern int fdflush_main(int argc, char **argv)
{
- int value;
int fd;
if (argc <= 1 || **(++argv) == '-')
usage(fdflush_usage);
- fd = open(*argv, 0);
- if (fd < 0) {
- perror(*argv);
- return EXIT_FAILURE;
- }
+ if ((fd = open(*argv, 0)) < 0)
+ perror_msg_and_die("%s", *argv);
- value = ioctl(fd, FDFLUSH, 0);
- /* Don't bother closing. Exit does
- * that, so we can save a few bytes */
- /* close(fd); */
+ if (ioctl(fd, FDFLUSH, 0))
+ perror_msg_and_die("%s", *argv);
- if (value) {
- perror(*argv);
- return EXIT_FAILURE;
- }
return EXIT_SUCCESS;
}
int fd;
long size;
- fd = open(file, O_RDWR);
- if (fd < 0) {
- perror(file);
- exit(1);
- }
+ if ((fd = open(file, O_RDWR)) < 0)
+ perror_msg_and_die("%s", file);
if (ioctl(fd, BLKGETSIZE, &size) >= 0) {
close(fd);
return (size * 512);
int fd;
long size;
- fd = open(file, O_RDONLY);
- if (fd < 0) {
- perror(file);
- exit(1);
- }
+ if ((fd = open(file, O_RDONLY)) < 0)
+ perror_msg_and_die("%s", file);
if (ioctl(fd, BLKGETSIZE, &size) >= 0) {
int sectors_per_page = pagesize / 512;
}
DEV = open(device_name, O_RDWR);
- if (DEV < 0 || fstat(DEV, &statbuf) < 0) {
- perror(device_name);
- return EXIT_FAILURE;
- }
+ if (DEV < 0 || fstat(DEV, &statbuf) < 0)
+ perror_msg_and_die("%s", device_name);
if (!S_ISBLK(statbuf.st_mode))
check = 0;
else if (statbuf.st_rdev == 0x0300 || statbuf.st_rdev == 0x0340)
}
endmntent(mountTable);
} else {
- perror(mtab_file);
+ perror_msg_and_die("%s", mtab_file);
}
return EXIT_SUCCESS;
}
else
status = swapoff(device);
- if (status != 0) {
- perror(applet_name);
- exit(EXIT_FAILURE);
- }
+ if (status != 0)
+ perror_msg_and_die(applet_name);
}
static void do_em_all()
struct mntent *m;
FILE *f = setmntent("/etc/fstab", "r");
- if (f == NULL) {
- perror("/etc/fstab");
- exit(FALSE);
- }
+ if (f == NULL)
+ perror_msg_and_die("/etc/fstab");
while ((m = getmntent(f)) != NULL) {
if (strcmp(m->mnt_type, MNTTYPE_SWAP)==0) {
swap_enable_disable(m->mnt_fsname);
if (status != 0) {
/* Don't bother retrying the umount on busy devices */
if (errno == EBUSY) {
- perror(mountpt);
+ perror_msg("%s", mountpt);
continue;
}
status = do_umount(mountpt, useMtab);
}
if (do_umount(*argv, useMtab) == TRUE)
return EXIT_SUCCESS;
- perror("umount");
- return EXIT_FAILURE;
+ perror_msg_and_die("%s", *argv);
}
int major = 0, minor = 0, patch = 0;
if (uname(&name) == -1) {
- perror("cannot get system information");
+ perror_msg("cannot get system information");
return (0);
}
major = atoi(strtok(name.release, "."));
status = lstat(srcName, &srcStatBuf);
if (status < 0) {
- perror(srcName);
+ perror_msg("%s", srcName);
return FALSE;
}
/* Make sure the directory is writable */
status = mkdir(destName, 0777777 ^ umask(0));
if (status < 0 && errno != EEXIST) {
- perror(destName);
+ perror_msg("%s", destName);
return FALSE;
}
} else if (S_ISLNK(srcStatBuf.st_mode)) {
/* Warning: This could possibly truncate silently, to BUFSIZ chars */
link_size = readlink(srcName, &link_val[0], BUFSIZ);
if (link_size < 0) {
- perror(srcName);
+ perror_msg("%s", srcName);
return FALSE;
}
link_val[link_size] = '\0';
status = symlink(link_val, destName);
if (status < 0) {
- perror(destName);
+ perror_msg("%s", destName);
return FALSE;
}
#if (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1)
} else if (S_ISFIFO(srcStatBuf.st_mode)) {
//fprintf(stderr, "copying fifo %s to %s\n", srcName, destName);
if (mkfifo(destName, 0644) < 0) {
- perror(destName);
+ perror_msg("%s", destName);
return FALSE;
}
} else if (S_ISBLK(srcStatBuf.st_mode) || S_ISCHR(srcStatBuf.st_mode)
|| S_ISSOCK(srcStatBuf.st_mode)) {
//fprintf(stderr, "copying soc, blk, or chr %s to %s\n", srcName, destName);
if (mknod(destName, srcStatBuf.st_mode, srcStatBuf.st_rdev) < 0) {
- perror(destName);
+ perror_msg("%s", destName);
return FALSE;
}
} else if (S_ISREG(srcStatBuf.st_mode)) {
//fprintf(stderr, "copying regular file %s to %s\n", srcName, destName);
rfd = open(srcName, O_RDONLY);
if (rfd < 0) {
- perror(srcName);
+ perror_msg("%s", srcName);
return FALSE;
}
wfd = open(destName, O_WRONLY | O_CREAT | O_TRUNC,
srcStatBuf.st_mode);
if (wfd < 0) {
- perror(destName);
+ perror_msg("%s", destName);
close(rfd);
return FALSE;
}
if (setModes == TRUE) {
/* This is fine, since symlinks never get here */
- if (chown(destName, srcStatBuf.st_uid, srcStatBuf.st_gid) < 0) {
- perror(destName);
- exit(EXIT_FAILURE);
- }
- if (chmod(destName, srcStatBuf.st_mode) < 0) {
- perror(destName);
- exit(EXIT_FAILURE);
- }
+ if (chown(destName, srcStatBuf.st_uid, srcStatBuf.st_gid) < 0)
+ perror_msg_and_die("%s", destName);
+ if (chmod(destName, srcStatBuf.st_mode) < 0)
+ perror_msg_and_die("%s", destName);
times.actime = srcStatBuf.st_atime;
times.modtime = srcStatBuf.st_mtime;
- if (utime(destName, ×) < 0) {
- perror(destName);
- exit(EXIT_FAILURE);
- }
+ if (utime(destName, ×) < 0)
+ perror_msg_and_die("%s", destName);
}
return TRUE;
error_exit:
- perror(destName);
+ perror_msg("%s", destName);
close(rfd);
close(wfd);
*cpOld = '\0';
retVal = mkdir(buf, cp ? 0777 : mode);
if (retVal != 0 && errno != EEXIST) {
- perror(buf);
+ perror_msg("%s", buf);
return FALSE;
}
*cpOld = '/';
int fd;
if ((fd = open(device, O_RDONLY)) < 0) {
- perror(device);
+ perror_msg("%s", device);
return (FALSE);
}
if (ioctl(fd, LOOP_CLR_FD, 0) < 0) {
- perror("ioctl: LOOP_CLR_FD");
+ perror_msg("ioctl: LOOP_CLR_FD");
return (FALSE);
}
close(fd);
mode = *loopro ? O_RDONLY : O_RDWR;
if ((ffd = open(file, mode)) < 0 && !*loopro
&& (errno != EROFS || (ffd = open(file, mode = O_RDONLY)) < 0)) {
- perror(file);
+ perror_msg("%s", file);
return 1;
}
if ((fd = open(device, mode)) < 0) {
close(ffd);
- perror(device);
+ perror_msg("%s", device);
return 1;
}
*loopro = (mode == O_RDONLY);
loopinfo.lo_encrypt_key_size = 0;
if (ioctl(fd, LOOP_SET_FD, ffd) < 0) {
- perror("ioctl: LOOP_SET_FD");
+ perror_msg("ioctl: LOOP_SET_FD");
close(fd);
close(ffd);
return 1;
}
if (ioctl(fd, LOOP_SET_STATUS, &loopinfo) < 0) {
(void) ioctl(fd, LOOP_CLR_FD, 0);
- perror("ioctl: LOOP_SET_STATUS");
+ perror_msg("ioctl: LOOP_SET_STATUS");
close(fd);
close(ffd);
return 1;
strcat(execstr, cmd_to_be_executed);
strcat(execstr, file_to_act_on);
cmd_output = popen(execstr, "r");
- if (cmd_output == NULL) {
- perror("popen");
- exit(1);
- }
+ if (cmd_output == NULL)
+ perror_msg_and_die("popen");
/* harvest the output */
while ((output_line = get_line_from_file(cmd_output)) != NULL) {