Xref: utzoo comp.unix.questions:5820 comp.unix.wizards:6704 Path: utzoo!mnetor!uunet!mcvax!botter!star!sjoerd From: sjoerd@cs.vu.nl (Sjoerd Mullender) Newsgroups: comp.unix.questions,comp.unix.wizards Subject: Re: Weird things in csh (and kernel?) Message-ID: <662@sjoerd.cs.vu.nl> Date: 25 Feb 88 10:17:29 GMT References: <1193@ark.cs.vu.nl> Reply-To: sjoerd@cs.vu.nl (Sjoerd Mullender) Followup-To: comp.unix.questions Organization: VU Informatica, Amsterdam Lines: 46 Keywords: csh, script Summary: Nothing weird. In article <1193@ark.cs.vu.nl> maart@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@cs.vu.nl When this doesn't work try sending via seismo.css.gov or mcvax.uucp.