diff --git a/mkfifo.1 b/mkfifo.1 index 8ff8da3..0f60d87 100644 --- a/mkfifo.1 +++ b/mkfifo.1 @@ -3,9 +3,17 @@ mkfifo \- make named pipe .SH SYNOPSIS .B mkfifo -.RI [ name ...] +.RB [ \-m +.IR mode ] +.I name ... .SH DESCRIPTION .B mkfifo creates named pipes (FIFOs) with the given names. +.SH OPTIONS +.TP +.B \-m +Set the file permission bits of newly created FIFOs to mode. The mode +is specified in octal as we do not currently support all the formats that +the chmod(1) utility supports. .SH SEE ALSO .IR mkfifo (3) diff --git a/mkfifo.c b/mkfifo.c index 24015fe..3f2d618 100644 --- a/mkfifo.c +++ b/mkfifo.c @@ -8,13 +8,19 @@ static void usage(void) { - eprintf("usage: %s name...\n", argv0); + eprintf("usage: %s [-m mode] name...\n", argv0); } int main(int argc, char *argv[]) { + mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | + S_IWGRP | S_IROTH | S_IWOTH; + ARGBEGIN { + case 'm': + mode = estrtol(EARGF(usage()), 8); + break; default: usage(); } ARGEND; @@ -22,12 +28,9 @@ main(int argc, char *argv[]) if (argc < 1) usage(); - for(; argc > 0; argc--, argv++) { - if(mkfifo(argv[0], S_IRUSR|S_IWUSR|S_IRGRP|\ - S_IWGRP|S_IROTH|S_IWOTH) == -1) { + for(; argc > 0; argc--, argv++) + if(mkfifo(argv[0], mode) == -1) eprintf("mkfifo %s:", argv[0]); - } - } return EXIT_SUCCESS; }