1
0
mirror of git://git.suckless.org/sbase synced 2024-12-30 19:22:07 +00:00
sbase/mkfifo.c

36 lines
604 B
C
Raw Normal View History

2011-05-25 10:00:15 +00:00
/* See LICENSE file for copyright and license details. */
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/stat.h>
#include "util.h"
2013-06-14 18:20:47 +00:00
static void
usage(void)
{
2013-11-30 20:56:34 +00:00
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[])
{
2013-11-30 20:56:34 +00:00
mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP |
S_IWGRP | S_IROTH | S_IWOTH;
2013-06-14 18:20:47 +00:00
ARGBEGIN {
2013-11-30 20:56:34 +00:00
case 'm':
mode = estrtol(EARGF(usage()), 8);
break;
2013-06-14 18:20:47 +00:00
default:
usage();
} ARGEND;
if (argc < 1)
usage();
2013-11-30 20:56:34 +00:00
for(; argc > 0; argc--, argv++)
if(mkfifo(argv[0], mode) == -1)
2013-06-14 18:20:47 +00:00
eprintf("mkfifo %s:", argv[0]);
return EXIT_SUCCESS;
2011-05-25 10:00:15 +00:00
}