Hi,

On Wed, Mar 16, 2005 at 03:44:20PM +0200, Tuomo Valkonen wrote:
> On 2005-03-16 14:17 +0100, Stefan Wehr wrote:
> > The problem is now: how to start the sync-script? The call
> > ioncore.exec('xterm -e sync-script') does not block until the script
> > has finished and so shutdown proceeds without finishing the
> > sync-script. Is there some way to program the desired behavior?
> 
> os.execute blocks but blocking means the wm won't be able to handle
> requests to map the window and thus it won't appear. Maybe start the
> program ioncore.popen_bgread? (I've been thinking of adding better
> pipe and sigchld support too so that error messages of short-lived
> programs could be grabbed etc.) 

I have now a working solution using ioncore.popen_bgread:

function my_shutdown() 
  ioncore.popen_bgread('~/.ion3/shutdown.sh > /dev/null 2> /dev/null', 
                       ioncore.shutdown)
end

-- Session control menu
defmenu("exitmenu", {
    menuentry("Restart",        "ioncore.restart()"),
    menuentry("Exit",           "my_shutdown()"),
})

The script ~/.ion3/shutdown.sh just calls the programs which should
run at the end of the ion session. The shell redirections ensure that
the 2nd argument of popen_bgread is not called to early.

A nicer solution would be the ability the pass an optional argument to
one of the exec functions. This optional argument would be a function
accepting the exit code of the program executed by exec. The function
would then be called after the program has exited.

Regards,
Stefan Wehr

-- 
Stefan Wehr
Web:  http://www.stefanwehr.de
PGP:  Key is available from pgp.mit.edu, ID 0B9F5CE4

Reply via email to