view toys/mkfifo.c @ 241:4121825716b8

Fix crash when running unknown command via symlink. (The error message was trying to print an uninitialied field. Oops.)
author Rob Landley <>
date Tue, 22 Jan 2008 15:33:50 -0600
parents 7cb15eae1664
children 951110c37fee
line wrap: on
line source

/* vi: set sw=4 ts=4:
 * mkfifo.c: Create a named pipe.
 * See


config MKFIFO
	bool "mkfifo"
	default y
	  usage: mkfifo [-m mode] name...

	  Makes a named pipe at name.

	  -m mode	The mode of the pipe(s) created by mkfifo. It defaults
			to 0644.  This number is in octal, optionally preceded
			by a leading zero.

#include "toys.h"

	char *mode;

#define TT this.mkfifo

void mkfifo_main(void)
	char *arg;
	int i;
	mode_t mode;

	if (toys.optflags) {
		char *end;
		mode = (mode_t)strtol(TT.mode, &end, 8);
		if (end<=TT.mode || *end || mode<0 || mode>0777)
			error_exit("Invalid mode");
	} else mode = 0644;

	for (i = 0; (arg = toys.optargs[i]); i++)
		if (mkfifo(arg, mode))