Pre-Logout Script

Mike Perry mike at cogsmos.com
Sun Nov 18 20:26:54 CET 2012


Hey,

>From the looks of your script you are sending a SIGTERM which is causing
vmplayer to suspend. Kind of odd that when it gets a SIGTERM it is
suspending, but acting different on a SIGHUP.

When you launch vmplayer you can easily ignore the HUP with the 'nohup'
command. If it is a gui application, I'm not too certain how it will handle
that though. What may be better is to make a launch script that traps
SIGHUP and upon receiving it sends a SIGTERM to the vmplayer pid instead.
Maybe something like:

#!/bin/bash

trap 'kill -TERM $_CHILD' HUP
nohup /path/to/vmplayer $* &
_CHILD=$!

wait $_CHILD

I dunno, just a thought.

If you come up with something else you could probably simplify your
shutdown script by using 'pidof' or 'pgrep'

Cheers

/*
 * Mike Perry
 * mike at cogsmos.com
 */


On Sun, Nov 18, 2012 at 2:04 PM, Erik Habicht <erik.habicht at gmail.com>wrote:

>  Hi Mike,
>
> this sound like an interesting solution. I never heard about 'trap'. Now i
> know it. :-) But how can i ensure that the trap trigger before the vmplayer
> get the SIPHUP signal?
>
> Best regards,
>   erik
>
>
> On 18.11.2012 17:18, Mike Perry wrote:
>
> How about adding a script to your startup that traps SIGHUP and just hangs
> out until it gets the signal. The trap could call your logout script.
>
> /*
>  * Mike Perry
>  * mike at cogsmos.com
>  */
>
>
> On Sun, Nov 18, 2012 at 8:44 AM, Tim <tim at xendistar.co.uk> wrote:
>
>> On 18/11/12 11:57, Erik Habicht wrote:
>>
>>
>>>
>>> On Sun, Nov 18, 2012 at 11:24 AM, Tim <tim at xendistar.co.uk <mailto:
>>> tim at xendistar.co.uk>> wrote:
>>>
>>>     On 17/11/12 20:32, Erik Habicht wrote:
>>>
>>>         Hi List,
>>>
>>>         is there a way to run a Script before logout?
>>>
>>>         I use the vmplayer and every time i forget to shutdown or
>>>         suspend the virtual machine before logout it get -KILLed. I
>>>         think it's like turn off your PC by pulling the power plug.
>>>
>>>         I wrote a script that send kill -TERM to the vmplayer and wait
>>>         until the vmplayer disappear from the process list. Now i need
>>>         to run the Script before logout.
>>>
>>>         Maybe someone can help me with this problem.
>>>
>>>         Best regards,
>>>            eriK
>>>
>>>     Cant you put the scripts in /etc/rc0.d (for shutdown) and
>>>     /etc/rc6.d (for reboots)
>>>
>>>
>>> Thank you, but that's executes to late. All windows are already closed
>>> at this moment.
>>>
>>>
>>>     I am only asking as I don't know the answer but if I was wanting
>>>     to run a script that where I would start?
>>>
>>>
>>>   Could not simply add the shutdown\reboot command to the end your
>> script and go from there? Although I guess that is more of a work around
>> than solving your original problem
>>
>> Tim
>>
>>
>> _______________________________________________
>> Xfce mailing list
>> Xfce at xfce.org
>> https://mail.xfce.org/mailman/listinfo/xfce
>> http://www.xfce.org
>>
>
>
>
> _______________________________________________
> Xfce mailing listXfce at xfce.orghttps://mail.xfce.org/mailman/listinfo/xfcehttp://www.xfce.org
>
>
>
> _______________________________________________
> Xfce mailing list
> Xfce at xfce.org
> https://mail.xfce.org/mailman/listinfo/xfce
> http://www.xfce.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.xfce.org/pipermail/xfce/attachments/20121118/b26741be/attachment.html>


More information about the Xfce mailing list