*BSD News Article 80728


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.carno.net.au!harbinger.cc.monash.edu.au!munnari.OZ.AU!news.ecn.uoknor.edu!solace!xinit!newsfeed.tip.net!news.seinf.abb.se!erinews.ericsson.se!cnn.exu.ericsson.se!uunet!in3.uu.net!news.artisoft.com!usenet
From: Terry Lambert <terry@lambert.org>
Newsgroups: comp.unix.bsd.freebsd.misc
Subject: Re: FreeBSD quirks.. help!
Date: Mon, 14 Oct 1996 11:53:27 -0700
Organization: Me
Lines: 50
Message-ID: <32628C27.5975A6E6@lambert.org>
References: <96288.1350433CQBJOZ@cmuvm.csv.cmich.edu>
NNTP-Posting-Host: hecate.artisoft.com
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Mailer: Mozilla 2.01 (X11; I; Linux 1.1.76 i486)

ishwar rattan wrote:
] 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.

[ ... attempting to create a named pipe with mknod() instead of
      the POSIX mandated function mkfifo() ... ]

Use mkfifo() instead.  You can't make FIFO's with mknod(), you can
only make nodes.  8-).

Personally, I dislike this piece of the POSIX standard.  It smacks
of gratuitous incompatability... but hey, it's POSIX.


] 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?

The csh attempts to determine the shell type by looking for a
magic number at the front.  It looks for ":\n" and it looks for
"#!"; if these aren't there, it assumes it's not a script and
terminates.

The Bourne shell (sh) attempts to exec the image, which, if it has
a ":\n" indicating a Bourne shell script, or a "#!<interpreter>",
will invoke the Bourse shell or some named interpreter on it.

The default behaviour for the Bourne shell is to attempt to run
the file as a script (obviously, if it won't exec and it's marked
executable, it must be a script -- and the Bourne shell is the
default UNIX-defined shell, so it attempts to run it itself as
a text stream.

Technically, you could argue that sh was right and csh was wrong,
and that the failure was because the user (you) incorrectly
marked the file executable on a system where it wasn't... in
other words, csh is wrong and sh gives the results it does
because of pilot error.


					Regards,
                                        Terry Lambert
                                        terry@lambert.org
---
Any opinions in this posting are my own and not those of my present
or previous employers.