Named Pipe Creation

T. William Wells bill at twwells.com
Sun Jul 2 13:36:24 AEST 1989


In article <163 at cerc.wvu.wvnet.edu.edu> drs at cerc.wvu.wvnet.edu (Darrell Schiebel) writes:
: I am attempting to create a named pipe which several different users
: can read from and write to, but when I create the pipe with:
:
:       if (mknod(destination_path,S_IFIFO | 0666, 0) == -1)
:         if (errno != EEXIST)
:           return(-1);
:         else errno = 0;
:
:       sock = open(destination_path,O_RDWR);
:
: the system creates a pipe with owner r/w, group r, and world r.  The
: protection I was expecting is owner r/w , group r/w, wnd world r/w.

Surround your code with something like:

	savemask = umask(0);
	...
	(void)umask(savemask);

after, RTFM'ing.

BTW, it looks like you are trying to be clever with errno. Don't. The
only thing you are guaranteed by the documentation is that it is set
properly after a system call returns an error. For all you know, errno
could be set to a random value on success.

---
Bill                    { uunet | novavax | ankh | sunvice } !twwells!bill
bill at twwells.com



More information about the Comp.unix.wizards mailing list