praveenzx has asked for the wisdom of the Perl Monks concerning the following question:

i tried to run a command, ie like `perl command 2>&1 > /dev/null &` , command will execute a perl script and the script will run some Linux command like lvcreate , dd_rescue and lvremove and some file write operations, i thought that the command will run in background . and so that i can load my browser with the message that its under progress , but its not happening , my browser loads partially and waiting for the process to get completed. i don't want my browser to wait for that process to get completed .. can any one advice me to solve this problem ,
  • Comment on Problem : Browser waiting for the background process get completed ..

Replies are listed 'Best First'.
Re: Problem : Browser waiting for the background process get completed ..
by Corion (Patriarch) on Oct 02, 2008 at 07:14 UTC
Re: Problem : Browser waiting for the background process get completed ..
by ikegami (Patriarch) on Oct 02, 2008 at 06:48 UTC
Re: Problem : Browser waiting for the background process get completed ..
by smiffy (Pilgrim) on Oct 02, 2008 at 10:25 UTC

    Please note that the suggested solutions rely on the META REFRESH technique which is regarded as bad practice in web accessibility[1] circles. (And could thus get you into trouble with local disability discrimination laws.) The reason for this is that automated page refreshes can cause major headaches for users of screen readers and other assistive/adaptive technologies. Refreshes can also take place too fast for those who may be slow readers - for whatever reason.

    I'll probably get shouted down for saying this because this usage is so common and that web accessibility is sadly less known about/understood than it might be; however, it is an issue, and one of which all producers of web content should be aware.

    Having said all that, let's look at the proposed solutions. In essence, we fire off the process, store the result somewhere, then go and look at it. Yes, a session cookie is a good way to maintain state between the 'searching' and 'search results' (or whatever) pages. You could also preserve state by putting something in the query string like http:// .... /foo?jobid=1234. Not as neat as a cookie, but just showing that there's more than one way to do it. (Now where have I heard that before?)

    The thing that does not need to be the same as the proposed solutions is the page refresh. We could have a scripted refresh which could be turned off as a user preference (again, maintain this state with cookies) and a link or button that can allow the subsequent page to be loaded manually.

    References

    1. Web Content Accessibility Guidelines
    2. From the Web Content Accessibility Guidelines, this article covers auto-forwarding specifically.
    3. This article doesn't specifically refer to accessibility but note Reason 2 (breaking the Back Button) causes problems for some disabled users.

    Update

    In addition to the two new links that I have just added above, I have received various comments from my learned colleagues in the web accessibility field. I would consider these to be out-of-scope for Perl Monks but would be willing to produce a brief meta-article on my blog which I can link from here if anyone wants to look at this further. Generally, the gist is "don't take control away from the user". Monks are invited to /msg or e-mail me if they think that elaboration would be useful.

Re: Problem : Browser waiting for the background process get completed ..
by JavaFan (Canon) on Oct 02, 2008 at 09:42 UTC
    You may want to read perlipc, in particular the section Complete Dissociation of Child from Parent.