blob: 17d9c2cbb0e227f547463d89cbdcf8e236739554 [file] [log] [blame]
Georgi Chorbadzhiyskif656fc92012-03-06 20:58:13 -06001/* vi: set sw=4 ts=4:
2 *
3 * mkfifo.c - Create FIFOs (named pipes)
4 *
5 * Copyright 2012 Georgi Chorbadzhiyski <georgi@unixsol.org>
6 *
7 * See http://pubs.opengroup.org/onlinepubs/009695399/utilities/mkfifo.html
8 *
9 * TODO: Add -m
10
11USE_MKFIFO(NEWTOY(mkfifo, "<1", TOYFLAG_BIN))
12
13config MKFIFO
14 bool "mkfifo"
15 default y
16 help
17 usage: mkfifo [fifo_name...]
Georgi Chorbadzhiyskif656fc92012-03-06 20:58:13 -060018
Rob Landleye430db22012-03-06 21:19:57 -060019 Create FIFOs (named pipes).
Georgi Chorbadzhiyskif656fc92012-03-06 20:58:13 -060020*/
21
22#include "toys.h"
23
Rob Landleye430db22012-03-06 21:19:57 -060024DEFINE_GLOBALS(
25 long mode;
26)
27
28#define TT this.mkfifo
29
Georgi Chorbadzhiyskif656fc92012-03-06 20:58:13 -060030void mkfifo_main(void)
31{
32 char **s;
Rob Landleye430db22012-03-06 21:19:57 -060033
34 TT.mode = 0666;
35
Georgi Chorbadzhiyskif656fc92012-03-06 20:58:13 -060036 for (s = toys.optargs; *s; s++) {
Rob Landleye430db22012-03-06 21:19:57 -060037 if (mknod(*s, S_IFIFO | TT.mode, 0) < 0) {
38 perror_msg("cannot create fifo '%s'", *s);
Georgi Chorbadzhiyskif656fc92012-03-06 20:58:13 -060039 toys.exitval = 1;
40 }
41 }
42}