morpheus-base

morpheus base system
git clone git://git.2f30.org/morpheus-base
Log | Files | Refs

mkfifo.c (634B)


      1 /* See LICENSE file for copyright and license details. */
      2 #include <fcntl.h>
      3 #include <stdlib.h>
      4 #include <sys/stat.h>
      5 #include <unistd.h>
      6 
      7 #include "util.h"
      8 
      9 static void
     10 usage(void)
     11 {
     12 	eprintf("usage: %s [-m mode] name...\n", argv0);
     13 }
     14 
     15 int
     16 main(int argc, char *argv[])
     17 {
     18 	mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP |
     19 		S_IWGRP | S_IROTH | S_IWOTH;
     20 	int ret = 0;
     21 
     22 	ARGBEGIN {
     23 	case 'm':
     24 		mode = estrtol(EARGF(usage()), 8);
     25 		break;
     26 	default:
     27 		usage();
     28 	} ARGEND;
     29 
     30 	if (argc < 1)
     31 		usage();
     32 
     33 	for (; argc > 0; argc--, argv++) {
     34 		if (mkfifo(argv[0], mode) < 0) {
     35 			weprintf("mkfifo %s:", argv[0]);
     36 			ret = 1;
     37 		}
     38 	}
     39 	return ret;
     40 }