mkfifo.c revision 27647
126236Swpaul/*
226236Swpaul * Copyright (c) 1990, 1993
326236Swpaul *	The Regents of the University of California.  All rights reserved.
426236Swpaul *
526236Swpaul * Redistribution and use in source and binary forms, with or without
626236Swpaul * modification, are permitted provided that the following conditions
726236Swpaul * are met:
826236Swpaul * 1. Redistributions of source code must retain the above copyright
926236Swpaul *    notice, this list of conditions and the following disclaimer.
1026236Swpaul * 2. Redistributions in binary form must reproduce the above copyright
1126236Swpaul *    notice, this list of conditions and the following disclaimer in the
1226236Swpaul *    documentation and/or other materials provided with the distribution.
1326236Swpaul * 3. All advertising materials mentioning features or use of this software
1426236Swpaul *    must display the following acknowledgement:
1526236Swpaul *	This product includes software developed by the University of
1626236Swpaul *	California, Berkeley and its contributors.
1726236Swpaul * 4. Neither the name of the University nor the names of its contributors
1826236Swpaul *    may be used to endorse or promote products derived from this software
1926236Swpaul *    without specific prior written permission.
2026236Swpaul *
2126236Swpaul * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2226236Swpaul * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2326236Swpaul * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2426236Swpaul * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2526236Swpaul * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2626236Swpaul * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2726236Swpaul * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2826236Swpaul * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2926236Swpaul * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3026236Swpaul * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3126236Swpaul * SUCH DAMAGE.
3226236Swpaul */
3326236Swpaul
3426236Swpaul#ifndef lint
3526236Swpaulstatic const char copyright[] =
3626236Swpaul"@(#) Copyright (c) 1990, 1993\n\
3726236Swpaul	The Regents of the University of California.  All rights reserved.\n";
3826236Swpaul#endif /* not lint */
39114601Sobrien
40114601Sobrien#ifndef lint
4130378Scharnier#if 0
4226236Swpaulstatic char sccsid[] = "@(#)mkfifo.c	8.2 (Berkeley) 1/5/94";
4326236Swpaul#endif
4426236Swpaulstatic const char rcsid[] =
4526236Swpaul	"$Id$";
4626236Swpaul#endif /* not lint */
4726236Swpaul
4826236Swpaul#include <sys/types.h>
4926236Swpaul#include <sys/stat.h>
5026236Swpaul
5126236Swpaul#include <err.h>
5226236Swpaul#include <stdio.h>
5326236Swpaul#include <string.h>
5426236Swpaul#include <unistd.h>
5526236Swpaul
5626236Swpaulstatic void usage __P((void));
5726236Swpaul
5826236Swpaulint
5926236Swpaulmain(argc, argv)
6026236Swpaul	int argc;
6126236Swpaul	char *argv[];
6226236Swpaul{
6326236Swpaul	extern int optind;
6426236Swpaul	int ch, exitval;
6526236Swpaul
6626236Swpaul	while ((ch = getopt(argc, argv, "")) != -1)
6790298Sdes		switch(ch) {
6890298Sdes		case '?':
6926236Swpaul		default:
7026236Swpaul			usage();
7126236Swpaul		}
7226236Swpaul	argc -= optind;
7326236Swpaul	argv += optind;
7426236Swpaul	if (argv[0] == NULL)
7526236Swpaul		usage();
7626236Swpaul
7726236Swpaul	for (exitval = 0; *argv != NULL; ++argv)
7826236Swpaul		if (mkfifo(*argv, S_IRWXU | S_IRWXG | S_IRWXO) < 0) {
7926236Swpaul			warn("%s", *argv);
8026236Swpaul			exitval = 1;
8126236Swpaul		}
8226236Swpaul	exit(exitval);
8326236Swpaul}
8426236Swpaul
8526236Swpaulstatic void
8626236Swpaulusage()
8726236Swpaul{
8826236Swpaul	(void)fprintf(stderr, "usage: mkfifo fifoname ...\n");
8926236Swpaul	exit(1);
9026236Swpaul}
9126236Swpaul