Return to BSD News archive
Path: euryale.cc.adfa.oz.au!newshost.carno.net.au!harbinger.cc.monash.edu.au!munnari.OZ.AU!spool.mu.edu!newspump.sol.net!howland.erols.net!news-peer.gsl.net!news.gsl.net!news.mathworks.com!uunet!news-in2.uu.net!caen!news.cmich.edu!3cqbjoz From: ishwar rattan <3CQBJOZ@cmuvm.csv.cmich.edu> Newsgroups: comp.unix.bsd.freebsd.misc Subject: FreeBSD quirks.. help! Date: Mon, 14 Oct 1996 13:50:43 EDT Organization: Central Michigan University Lines: 72 Message-ID: <96288.1350433CQBJOZ@cmuvm.csv.cmich.edu> NNTP-Posting-Host: cmuvm.csv.cmich.edu Disclaimer: Author bears full responsibility for this post Hello 1. I ran the following code under FreeBSD-2.1.5 and it terminates with error: Operation not permitted, mknod error. It seems that one has to have su privilige to create a named pipe??? The same code works under Solaris 1.x and 2.x. 2. A solaris 1.x binary image is correctly recognized under c-shell (terminates with Exec format error..) but `/bin/sh' seems to think it is a shell script and tries to interpret it :-( Any ideas? Ishwar Rattan ------------ /* A sample program using named pipes. It is used * for making related processes talk to each other. * Parent process writes to the pipe, and the child * process reads from the pipe. The system calls used * 1. int mknod(const char *path, mode_t mode, dev_t dev); (value of mode used is S_IFIFO defined in <sys/stat.h>) * 2. int unlink(char *path); */ #include <sys/errno.h> #include <sys/types.h> #include <unistd.h> #include <sys/stat.h> #include <stdio.h> #include <string.h> #define FIFO1 "./fifo" #define PERMS 0666 extern int errno; char *fromp = "hello, from parent!"; char *fromc = "hello, from child!!"; char buf[30]; main() { int cid, len, rfd, wfd; if(mknod(FIFO1, S_IFIFO | S_IRUSR | S_IWUSR, 0) < 0){ perror(strerror(errno)); xit("mknod error"); } if((cid = fork()) < 0) xit("fork error"); if( 0 == cid) { if((rfd = open(FIFO1, 0)) < 0) xit("open error"); len = read(rfd, buf, sizeof(buf)); if( len < 0) xit("read error"); printf("child: %s\n", buf); } else { len = strlen(fromp) + 1; if((wfd = open(FIFO1, 1)) < 0) xit("write error"); if(write(wfd, fromp, len) != len) xit("write error"); if(unlink(FIFO1) < 0) xit("unlink error"); exit(0); } } xit(reason) char *reason; { fprintf(stderr, "%s\n", reason); exit(127); } ----------