sbase/mkfifo.c

40 lines
547 B
C
Raw Normal View History

2011-05-25 10:00:15 +00:00
/* See LICENSE file for copyright and license details. */
#include <sys/stat.h>
2015-02-14 20:02:41 +00:00
#include <stdlib.h>
2011-05-25 10:00:15 +00:00
#include "util.h"
2013-06-14 18:20:47 +00:00
static void
usage(void)
{
eprintf("usage: %s [-m mode] name ...\n", argv0);
2013-06-14 18:20:47 +00:00
}
2011-05-25 10:00:15 +00:00
int
main(int argc, char *argv[])
{
mode_t mode = 0666;
int ret = 0;
2013-11-30 20:56:34 +00:00
2013-06-14 18:20:47 +00:00
ARGBEGIN {
2013-11-30 20:56:34 +00:00
case 'm':
mode = parsemode(EARGF(usage()), mode, umask(0));
2013-11-30 20:56:34 +00:00
break;
2013-06-14 18:20:47 +00:00
default:
usage();
} ARGEND
if (!argc)
usage();
for (; *argv; argc--, argv++) {
if (mkfifo(*argv, mode) < 0) {
weprintf("mkfifo %s:", *argv);
ret = 1;
}
}
return ret;
2011-05-25 10:00:15 +00:00
}