[clug] Launch gnome-terminal to launch daemon process

Hal Ashburner hal.ashburner at gmail.com
Tue Aug 25 03:17:23 UTC 2015


On 25 August 2015 at 13:14, Hal Ashburner <hal at ashburner.info> wrote:
> Extra fork is overkill and wasn't there initially.
> Likewise the disown in the command and the disown in the script it
> launches weren't there...
>
>
> The idea is a basic double fork.
> terminal
>  |-> bash
>          |->python
>
> so that when the terminal goes away it kills bash but leaves the
> python running to be inherited by init. Pretty fundamental to how unix
> works, I'd have thought.
>
> Note that if I run the script that launches the python and kill the
> terminal, that works fine and the python keeps running so I'm
> imagining the double fork is actually happening.
>
> The following works the way I expect it when I run it as a script in a
> terminal - double forks, kill that terminal, hgview stays. Unix works.
>
> #!/bin/bash
> cmd="exec /usr/bin/python /opt/ark/bin/hgview &"
> eval $cmd
>
>
> gnome-terminal --sm-client-disable
> --title="$cmd" --command "bash -c \"$the-above-script;
> ; echo done; sleep 36000\""
>
> Which really should be the same code with the same double fork working
> the same way (I'd have thought), just launched differently from the
> same terminal program - but hgview doesn't survive the terminal exit.
>
>
> xterm -e "bash -c \"$the-above-script; sleep 36000\""
>
> same behaviour - kill the xterm and it kills python/hgview
>
>
>
>
>
> On 25 August 2015 at 12:38, Andrew Janke <a.janke at gmail.com> wrote:
>> On 25 August 2015 at 12:22, Hal Ashburner <hal at ashburner.info> wrote:
>>> Why doesn't a regular double fork work?
>>> Why doesn't disowning the process work?
>>> What on earth is going on? Does gnome-terminal somehow break unix?
>>
>> I think the answers to the above questions is that I don't think the
>> disown is doing what you want in the --command argument and the -a
>> would mean that you aren't getting an error. I haven't tested but I
>> don't think that quoting is getting you. I'd use the -x argument over
>> --command to check.
>>
>>    gnome-terminal -x /usr/bin/python /opt/ark/bin/hgview | run now
>>
>> (I think the pipe will do the wrong thing here though).
>>
>> I don't see what your extra fork(s) in the command argument is achieving
>> beyond in this case probably more confusion.
>>
>>
>> a
>>
>> --
>> linux mailing list
>> linux at lists.samba.org
>> https://lists.samba.org/mailman/listinfo/linux



More information about the linux mailing list