Weird things in csh (and kernel?)
Sjoerd Mullender
sjoerd at cs.vu.nl
Thu Feb 25 20:17:29 AEST 1988
In article <1193 at ark.cs.vu.nl> maart at cs.vu.nl (Maarten Litmaath) writes:
>Has anyone noticed the following oddities?
>1)
> % a.out < a.out
> a.out: Text file busy.
> %
>
If you are debugging a.out then this could happen. Especially if you have set
breakpoints.
>Why shouldn't a process be able to read its text file?
It can!
>2)
> % cat ~/.cshrc
> echo echo hello
> % cp /bin/echo .
> % ./echo > echo
> hello: Command not found.
> % cat echo
> echo hello
> hello
> %
When executing the command "./echo > echo" the shell will first create the
file echo. It then tries to exec ./echo. The kernel refuses (it's not an
object anymore, it an empty file) and the shell will start interpreting the
script. The shell will fork off a new shell to do the work. This new shell
will first execute ~/.cshrc which contains the command "echo echo hello".
So the string "echo hello" is echoed into the output file (echo). Then the
shell really starts executing the script. It now contians the string
"echo hello", so that command is executed. The result (the string "hello")
is appended to the output file (that file was never closed or re-created).
After that the next line of the script is "hello" and the shell is not able
to find the command. Hence the error message.
>
>What kinda weird thing is going on here?
>Shouldn't there be an error message "Text file busy."
>in this case?
Nothing that cannot be explained.
Why was this cross-posted to comp.unix.wizards?
--
Sjoerd Mullender
sjoerd at cs.vu.nl
When this doesn't work try sending via seismo.css.gov or mcvax.uucp.
More information about the Comp.unix.questions
mailing list