Re: vzctl enter hangs
> That's what I got, and the strace points the finger at vzctl. It looks > like a bug in vzctl that was masked by bash-4.1 and previous versions. Thanks for the investigation. It is always difficult when two packages are working together and changing one of them breaks the cooperation :-). > Michael Kalisz opened a bug report with the openvz group. Found it and will ask to raise the severity. If someone installs the newest Bash it is in theory a DoS against the owner of the physical node :-). -- Henk van de Kamer http://www.vandekamer.com/ P.S. Al mijn e-mail is digitaal ondertekend om mij zo te beschermen tegen identiteitsdiefstal. Mocht uw mailprogramma hier niet goed mee overweg kunnen, lees dan mijn uitleg [1]. Sorry voor de overlast, maar in de toekomst zal u waarschijnlijk ook uw e-mail willen beschermen... [1] http://www.hetlab.tk/artikelen/digitale-handtekening smime.p7s Description: S/MIME Cryptographic Signature
Re: vzctl enter hangs
> Michael Kalisz opened a bug report with the openvz group. And the OpenVZ guys have just released a patch: http://bugzilla.openvz.org/show_bug.cgi?id=1812 I've tested it and the problem is solved. Thanks again for the help and of course all the efforts you put in this project! -- Henk van de Kamer http://www.vandekamer.com/ P.S. Al mijn e-mail is digitaal ondertekend om mij zo te beschermen tegen identiteitsdiefstal. Mocht uw mailprogramma hier niet goed mee overweg kunnen, lees dan mijn uitleg [1]. Sorry voor de overlast, maar in de toekomst zal u waarschijnlijk ook uw e-mail willen beschermen... [1] http://www.hetlab.tk/artikelen/digitale-handtekening smime.p7s Description: S/MIME Cryptographic Signature
Problem with open and rm
The script that follows is a cut down version of one that came from elsewhere. #!/bin/bash cp /tmp/x.html /tmp/$$.html ls /tmp/$$.html [ "$DISPLAY" ] && open /tmp/$$.html ls /tmp/$$.html rm -f /tmp/$$.html I'm on an Imac with OS X 10.6.6. If I run the script as it stands, the open tries to open /tmp/$$.html in a new tab in the Safari browser and fails with the message: No file exists at the address “/tmp/13551.html”. The terminal output is the following pair of lines, which suggest that the file is still around after open failed: /tmp/13551.html /tmp/13551.html If I comment out the final 'rm' line and run it again, I get what I want displayed (and a similar pair of lines on the terminal) but unfortunately the temporary file is left lying around. My two questions are: Why? How can I change the script so that I can both view the file and have it removed? Barrie.
Re: Problem with open and rm
(03/16/2011 03:54 AM), Barrie Stott wrote: > The script that follows is a cut down version of one that came from elsewhere. > > #!/bin/bash > > cp /tmp/x.html /tmp/$$.html > ls /tmp/$$.html > [ "$DISPLAY" ] && open /tmp/$$.html > ls /tmp/$$.html > rm -f /tmp/$$.html > > I'm on an Imac with OS X 10.6.6. If I run the script as it stands, the open > tries to open /tmp/$$.html in a new tab in the Safari browser and fails with > the message: No file exists at the address “/tmp/13551.html”. The terminal > output is the following pair of lines, which suggest that the file is still > around after open failed: > > /tmp/13551.html > /tmp/13551.html > > If I comment out the final 'rm' line and run it again, I get what I want > displayed (and a similar pair of lines on the terminal) but unfortunately the > temporary file is left lying around. > > My two questions are: > Why? >From the symptoms you describe, it seems extremly likely that the "open" command simply sends a message to Safari and exits. This exit may very well occur before Safari actually gets a chance to obey the message. This then produces a race: will Safari open the file before bash gets to and executes the "rm" command, or...? > How can I change the script so that I can both view the file and have it > removed? That depends on Safari, really. There's no way for a script to know whether Safari has opened the tab, unless Safari provides a means for knowing it. Perhaps open has an option that lets it block until Safari acknowledges having opened the file? If not, then probably the best you can do is a heuristic: sleep a couple seconds after evaluating "open", and then continue on. -- Good luck! Micah J. Cowan http://micah.cowan.name/
Re: Problem with open and rm
On Wed, Mar 16, 2011 at 10:54:15AM +, Barrie Stott wrote: > The script that follows is a cut down version of one that came from elsewhere. > > #!/bin/bash > > cp /tmp/x.html /tmp/$$.html > ls /tmp/$$.html > [ "$DISPLAY" ] && open /tmp/$$.html > ls /tmp/$$.html > rm -f /tmp/$$.html > If I comment out the final 'rm' line and run it again, I get what I want > displayed (and a similar pair of lines on the terminal) but unfortunately the > temporary file is left lying around. My guess would be that "open" sends a message to some other process (or creates a child process of its own, and detaches it), which takes some time to process the file. If you rm it before open gets a chance to process it, you get the "No such file" message. As a cheap workaround, you can just delay the rm a bit. Add a sleep command before it. A proper fix would be for open to allow you some means of finding out when it has, in fact, "opened" the target, so that you know when it's safe to remove it. I doubt you'll be able to do that, but hey, maybe I'm wrong.
Re: Problem with open and rm
On Wed, Mar 16, 2011 at 10:54:15AM +, Barrie Stott wrote: > The script that follows is a cut down version of one that came from elsewhere. > > #!/bin/bash > > cp /tmp/x.html /tmp/$$.html > ls /tmp/$$.html > [ "$DISPLAY" ] && open /tmp/$$.html > ls /tmp/$$.html > rm -f /tmp/$$.html > > I'm on an Imac with OS X 10.6.6. If I run the script as it stands, > the open tries to open /tmp/$$.html in a new tab in the Safari > browser and fails with the message: No file exists at the address > ?/tmp/13551.html?. The terminal output is the following pair of lines, > which suggest that the file is still around after open failed: > > /tmp/13551.html > /tmp/13551.html > > If I comment out the final 'rm' line and run it again, I get what > I want displayed (and a similar pair of lines on the terminal) but > unfortunately the temporary file is left lying around. > > My two questions are: > Why? Assuming open doesn't somehow block, the script is probably working and removing the file just after open is invoked. > How can I change the script so that I can both view the file and have > it removed? Adding sleep 30 before rm ought to leave it around for a while. Ken
Re: Problem with open and rm
On 03/16/2011 04:54 AM, Barrie Stott wrote: > The script that follows is a cut down version of one that came from elsewhere. > > #!/bin/bash > > cp /tmp/x.html /tmp/$$.html > ls /tmp/$$.html > [ "$DISPLAY" ] && open /tmp/$$.html > ls /tmp/$$.html > rm -f /tmp/$$.html Instead of passing Safari the name of a temporary file, why not pass it the name of a temporary pipe? Does this work any better: [ "$DISPLAY" ] && open <(cat /tmp/x.html) at which point there's no temporary file to remove. -- Eric Blake ebl...@redhat.com+1-801-349-2682 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature
Re: Problem with open and rm
Barrie Stott wrote: > The script that follows is a cut down version of one that came from > elsewhere. Thank you for your bug report but neither 'open' nor 'rm' have anything to do with bash. This is not a bug in the bash shell. This mailing list is for bug reports in the bash shell. > cp /tmp/x.html /tmp/$$.html > ls /tmp/$$.html > [ "$DISPLAY" ] && open /tmp/$$.html > ls /tmp/$$.html > rm -f /tmp/$$.html You have invoked open and then not waited for it to finish but instead removed the file it is going to work on. That is the problem. Open is launching in the background. Before it has a chance to run ls and rm are called in the script. Eventaully, some thousands of cpu cycles later, the action associated with open is called and by that time the file has been removed by the script. > My two questions are: > Why? > How can I change the script so that I can both view the file and > have it removed? See the man page for the Apple 'open' command. That is an Apple specific command not found on other systems. I do not have it available to me on my Debian GNU/Linux system for example. But I see an online man page for it here: http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man1/open.1.html Using that man page I see that open has a -W option. -W Causes open to wait until the applications it opens (or that were already open) have exited. Use with the -n flag to allow open to function as an appropriate app for the $EDITOR environment variable. Therefore I infer that if you add the -W option to open that it will then wait for the application. Try this: #!/bin/sh cp /tmp/x.html /tmp/$$.html ls /tmp/$$.html [ "$DISPLAY" ] && open -W /tmp/$$.html ls /tmp/$$.html rm -f /tmp/$$.html I do not have a Mac and have no way to test the above but the documentation leads me to believe that it will work. Bob