| View previous topic :: View next topic |
| Author |
Message |
sdutky n00b


Joined: 14 Sep 2006 Posts: 8 Location: Takoma Park MD
|
Posted: Tue Feb 27, 2007 12:08 pm Post subject: execve EXTBSY: nvi flock workaround |
|
|
On other unices, I typically arrange my desktop so that I edit perl script file in one terminal session while debugging it under perl in another. When I try this on gentoo (2.6.17-gentoo-r4) I envariably get the error message "<shell>: ./<script>: /usr/local/bin/perl: bad interpreter: Text file busy" with shell equal to either sh or bash.
strace turns up: [pid 29651] execve("./x", ["./x", "00:0E:38:82:B4:00"], [/* 46 vars */]) = -1 ETXTBSY (Text file busy)
man exeve(2) shows " ETXTBSY Executable was open for writing by one or more processes".
My question: who cares if someone has it open for writing? Why does the shell complain about this?
I can bypass the problem by debugging the script before opening it with an editor, but this has some drawbacks.
Does anybody have a way of getting the shell to ignore ETXBSY?
Thanks. _________________ Ever tried. Ever failed.
No matter.
Try Again. Fail again.
Fail better.
--Samuel Beckett
Last edited by sdutky on Thu Mar 08, 2007 10:18 am; edited 1 time in total |
|
| Back to top |
|
 |
nutznboltz Apprentice


Joined: 23 Apr 2004 Posts: 239 Location: 20012
|
Posted: Wed Mar 07, 2007 11:21 pm Post subject: Re: execve EXTBSY |
|
|
Running strace on app-editors/nvi-1.81.5-r3 shows:
| Code: | 1134 open("foo.pl", O_RDWR) = 5
1134 flock(5, LOCK_EX|LOCK_NB) = 0 | So it's really about nvi locking the file.
nvi man page mentions "set lock" / "set nolock" but those don't seem to unlock the file. |
|
| Back to top |
|
 |
sdutky n00b


Joined: 14 Sep 2006 Posts: 8 Location: Takoma Park MD
|
Posted: Thu Mar 08, 2007 10:30 am Post subject: |
|
|
Yup: it appears that the nvi lock causes the problem, and nvi/ex "set nolock" does not release the lock.
nvi opens read-only files as unlocked.
My workaround:
chmod -w <file>
nvi <file> # opens as read-only unlocked
!chmod +w <file> #from ex within nvi
from that point <file> remains unlocked an access by parallel processes run undeterred by EXTBSY.
Changes to <file> must be written out using nvi/ex w! write override.
Thanks _________________ Ever tried. Ever failed.
No matter.
Try Again. Fail again.
Fail better.
--Samuel Beckett |
|
| Back to top |
|
 |
nutznboltz Apprentice


Joined: 23 Apr 2004 Posts: 239 Location: 20012
|
Posted: Wed Mar 14, 2007 8:10 am Post subject: |
|
|
I am trying to reproduce this with app-editors/nvi-1.81.5-r3
1. echo hello > myfile
2. nvi myfile
3. :set nolock
4. ^Z
5. echo goodbye > myfile
but then that works and "myfile" gets overwritten.
Do you have a step list with how to reproduce the problem? Thanks.
Running
1. echo hello > myfile
2. nvi myfile
3. :set lock
4. ^Z
5. echo goodbye > myfile
Has no problem overwriting myfile either. |
|
| Back to top |
|
 |
sdutky n00b


Joined: 14 Sep 2006 Posts: 8 Location: Takoma Park MD
|
Posted: Thu Mar 15, 2007 12:54 pm Post subject: To reproduce the problem |
|
|
chmod +x myscript
nvi myscripy
:set lock
^Z
myscript
Should produce the "bad interpreter: text file busy" message. _________________ Ever tried. Ever failed.
No matter.
Try Again. Fail again.
Fail better.
--Samuel Beckett |
|
| Back to top |
|
 |
nutznboltz Apprentice


Joined: 23 Apr 2004 Posts: 239 Location: 20012
|
Posted: Thu Mar 15, 2007 2:06 pm Post subject: Re: To reproduce the problem |
|
|
| sdutky wrote: | chmod +x myscript
nvi myscripy
:set lock
^Z
myscript
Should produce the "bad interpreter: text file busy" message. |
But "set lock" should invoke that behavior. I think the bug is that "set nolock" doesn't prevent it.
| Code: | 1. echo -e "#! /bin/sh\necho hello" > runme
2. chmod 755 runme
3. nvi runme
4. :set nolock
5. ^Z
6. ./runme |
|
|
| Back to top |
|
 |
nutznboltz Apprentice


Joined: 23 Apr 2004 Posts: 239 Location: 20012
|
|
| Back to top |
|
 |
|