This is the mail archive of the mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: gawk : Input file remaining locked after program termination

Thank you for your answer. Comments follow.

> This will attempt to spawn a copy of notepad for every line in 
> the file foobar in background and then returns the command's status.  
> In other words gawk will not wait for the notepad command to 
> complete before moving to the next line in foobar and next instance 
> of a notepad process.
> So there could be a number of incomplete notepad instances running, 
> one of which is trying to access foobar.tmp when the mv command is 
> being executed.  This may be causing the effect that you describe.

This is precisely what was intended. I wanted to demonstrate that when
the process spawned by "system()" is still active after gawks's 
termination, the input file remains locked. I suspect that at some 
point gawk forks (or whatever other mechanism it uses) the "system()"
call but somehow does not close the file descriptors that where used
in the main process. I am not familiar with how cygwin deals with 
fork() and other such mechanisms, so this is only wild guessing. 

>> Running produced the following output :
>> mv: cannot create regular file `foobar': Permission denied
> This did not happen when I tried your exact commands on my system.
> [...]
> I don't think that this is a gawk issue - it may be your set up.
> Which version of Cygwin are you using?

I am using the latest version of Cygwin and gawk (updated weekly), 
running on a Windows 2000 box. 

It is surprising, yet interesting that you should not experience the 
same problem. Any suggestion anyone ?

> A few comments re: your gawk program.  This will fail if any of the
> files have spaces in their names, because you are using $1 as the
> name of the file to pass to notepad.  It would be more sensible to
> use $0 and to quote it when passing it to notepad, i.e.:
>    system ("notepad \"" $0"\" &")
That was just a minialist example program that would exhibit the 
problem, not my actual program (I use cygpath to convert the filename 
to the windows paradigm in "real life", notepad isn't even the program 
I launch from awk anyway...). 

> Oh, and awk isn't perl, so you don't need to end lines with ";"
Yes, I know... it's just an old C/C++ habit... I just happen to 
like it better this way, for the look of it :-) (I won't blame anyone 
who finds it stupid...)

Thanks again for your reply. 

Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts

Unsubscribe info:
Bug reporting:

Unsubscribe info:
Bug reporting:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]