command line question

Patrick Callahan patrick.pxc.c at gmail.com
Wed Jan 30 04:26:16 MST 2013


Behavior is different if you close the terminal emulator by calling 'exit'
from within the session inside it than if you click the x in the corner or
close the tab in Konsole. Without using something like nohup, even things
launched in the background are usually killed by clicking closing a
terminal emulator from the outside. They stay open if you just log out of
the session (at which point most terminal emulators just close themselves
anyway).

Using nohup fixes this weirdness. It doesn't occur with processes that
truly 'detach' themselves from the terminal, like those running inside
screen and tmux sessions. I think this has something to do with the fact
that closing a terminal emulator from the GUI is more like killing the
session than asking it to close, either backgrounded processes still
associated with that (p)tty can't cope with that, or they count as 'child'
processes and so they are implicated to and also receive whichever signal
is used to kill the terminal session.

Someone who really knows things about Unix shells can probably better
explain the real mechanism of action here, but anyway, the behavior is
different depending upon how the terminal emulator is closed.


On Tue, Jan 29, 2013 at 5:13 PM, Paul Mooring <paul at opscode.com> wrote:

> I did not know '&>' was a thing, thanks Kevin and Hans!
> --
> Paul Mooring
> Systems Engineer and Customer Advocate
>
> www.opscode.com
>
>
>
>
>
>
> On 1/29/13 4:18 PM, "der.hans" <PLUGd at LuftHans.com> wrote:
>
> >Am 29. Jan, 2013 schwätzte Kevin Fries so:
> >
> >moin moin Kevin,
> >
> >> I am surprised nobody gave this answer, at least as far as I saw:
> >>
> >>   $ /path/to/command &> /dev/null
> >
> >A couple of us did, except we spelled it correctly :)
> >
> >'&>/dev/null' is a bashism for '>/dev/null 2>&1'. There's nothing wrong
> >with it for bash scripting, but I find the latter to be easier to read,
> >far more common and more portable, so that's what I use for teaching and
> >giving answers on mailing lists.
> >
> >In a bash only environment, either is fine, but when working with other
> >Bourne shell derivatives your syntax might not work. It might work in
> >zsh, but I'm pretty certain it isn't allowed in POSIX shell or ksh and it
> >definitely isn't in the original Bourne shell.
> >
> >A really cool feature of a good toolset is there is more than one way to
> >do it :).
> >
> >ciao,
> >
> >der.hans
> >
> >> Kevin
> >> On Jan 29, 2013 3:27 PM, "Matt Graham" <danceswithcrows at usa.net> wrote:
> >>
> >>> From: joe at actionline.com
> >>>> I still can't get either to work.
> >>>> James: gwenview filename.jpg > /dev/null 2>&1 &
> >>>> Hans:  gwenview filename.jpg 2>/dev/null &
> >>>>
> >>>> Both examples work to cause gwenview to open filename.jpg without
> >>>> any error messages. However, when I close the terminal window,
> >>>> gwenview also closes.  What am I doing wrong?
> >>>
> >>> To stop a process from dying when its parent tty dies, you probably
> >>>want
> >>> nohup.  "nohup gwenview filename.jpg > /dev/null 2>&1 &" .  The
> >>> xterm/konsole
> >>> will still be there, though you can then manually close it.
> >>>
> >>> If this approach *did* automagically close the xterm, it'd be
> >>>functionally
> >>> equivalent to just starting gwenview from the mini-commandline....
> >>>
> >>> --
> >>> Matt G / Dances With Crows
> >>> The Crow202 Blog:  http://crow202.org/wordpress/
> >>> There is no Darkness in Eternity/But only Light too dim for us to see
> >>>
> >>> ---------------------------------------------------
> >>> PLUG-discuss mailing list - PLUG-discuss at lists.phxlinux.org
> >>> To subscribe, unsubscribe, or to change your mail settings:
> >>> http://lists.phxlinux.org/mailman/listinfo/plug-discuss
> >>>
> >>
> >
> >--
> >#  http://www.LuftHans.com/        http://www.LuftHans.com/Classes/
> >#  When I work, I work hard. When I play, I play hard.
> >#  When I sit, I sleep. - Embe Kugler
>
>
> ---------------------------------------------------
> PLUG-discuss mailing list - PLUG-discuss at lists.phxlinux.org
> To subscribe, unsubscribe, or to change your mail settings:
> http://lists.phxlinux.org/mailman/listinfo/plug-discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.phxlinux.org/pipermail/plug-discuss/attachments/20130130/5a8aa989/attachment.html>


More information about the PLUG-discuss mailing list