You are not logged in.
Using KDE, I can open konsole, type something like "kwrite &", close konsole and working happily with kwrite.
The same doesn't work with openbox: when i run a program from a terminal - with the final "&", of course - if I close the terminal the program exits.
Does someone have a clue?
Offline
try executing "bg" after you did "kwrite &"
bg sends it to the background, I believe you can close the terminal afterwards.
Offline
I have always ran things like this and it will close the terminal.
'application & exit'
Offline
Why not use something like gmrun and give it a keybinding? There's little point to opening a terminal, only to background a graphical application and then closing the terminal.
It seems to depend on the app whether it gets killed or not after you close the terminal.
@ hrobeers: & tells bash to background the app, bg is only needed for an app that's already running (and not backgrounded).
Got Leenucks? :: Arch: Power in simplicity :: Get Counted! Registered Linux User #392717 :: Blog thingy
Offline
Why not use something like gmrun and give it a keybinding? There's little point to opening a terminal, only to background a graphical application and then closing the terminal.
In that vien, I always liked http://bbs.archlinux.org/viewtopic.php?id=56283 or even better, dmenu.
Offline
Thanks all for your answers - I'll do some other test tonight.
Why not use something like gmrun and give it a keybinding? There's little point to opening a terminal, only to background a graphical application and then closing the terminal.
I agree: anyway, it should work but it's not working - that's what bugs me.
Most important, it works perfectly in KDE but not in Openbox - so I'm curious to know why.
It seems to depend on the app whether it gets killed or not after you close the terminal.
It seem that the issue arises with different terminals (konsole, terminator, xterm) and every apps I run from them (not only KDE apps).
Last edited by daneel971 (2009-09-17 04:55:22)
Offline
Interesting, maybe konsole forks a process ?
The day Microsoft makes a product that doesn't suck, is the day they make a vacuum cleaner.
--------------------------------------------------------------------------------------------------------------
But if they tell you that I've lost my mind, maybe it's not gone just a little hard to find...
Offline
Try
application > /dev/null 2>&1 &Or use the much more comfortable way B told you, gmrun is really nice!
Offline
bashrun/gmrun automatically keep the running process in the background, whereas starting from the console usually only forks.
Personally I prefer bashrun over gmrun. It has less dependencies.
OTH gmrun looks nicer.
Just a matter of taste.
To know or not to know ...
... the questions remain forever.
Offline
The bash command that you are looking for is disown.
If you disown the jobspec then SIGHUP won't be sent to it when the shell closes.
Knute
Offline
Army's suggestion doesn't work. Both nohup and disown work.
The question is: how come that in KDE I don't need anything special in order to launch a program from a terminal (with the final "&", of course) and then close the terminal, while in Openbox I need to explicit use nohup or disown?
BTW: I checked in openbox with shopt and I can confirm that huponexit is off.
Offline
Well, are you using the same terminal in both environments?
Knute
Offline
Well, are you using the same terminal in both environments?
Sure. In both environment I tried with Konsole and Terminator. Only in Openbox I tried even with Xterm.
The terminal (terminator and xterm) works as expected with Crunchbang (installable live-cd with openbox desktop): I took a look at various config files in Crunchbang, but I didn't notice anything "strange".
Offline
Trying to learn more about this behaviour:
It is the way an interactive bash shell works. To quote from man bash:
...
The shell exits by default upon receipt of a SIGHUP. Before exiting,
an interactive shell resends the SIGHUP to all jobs, running or
stopped. Stopped jobs are sent SIGCONT to ensure that they receive the
SIGHUP. To prevent the shell from sending the signal to a particular
job, it should be removed from the jobs table with the disown builtin
(see SHELL BUILTIN COMMANDS below) or marked to not receive SIGHUP
using disown -h.
...
disown [-ar] [-h] [jobspec ...]
Without options, each jobspec is removed from the table of
active jobs. If jobspec is not present, and neither -a nor -r
is supplied, the shell's notion of the current job is used. If
the -h option is given, each jobspec is not removed from the ta‐
ble, but is marked so that SIGHUP is not sent to the job if the
shell receives a SIGHUP. If no jobspec is present, and neither
the -a nor the -r option is supplied, the current job is used.
If no jobspec is supplied, the -a option means to remove or mark
all jobs; the -r option without a jobspec argument restricts
operation to running jobs. The return value is 0 unless a job‐
spec does not specify a valid job.
It looks like KDE disowns background processes by default. (Someone has to proof this, however.)
There are applications which obviously disown themselves, even in openbox, like e.g. conky & (if run from urxvt).
BTW: It is informative to follow this behaviour in htop.
To know or not to know ...
... the questions remain forever.
Offline
Another trick: if you put your command between parentheses, then the process will be child of init (process id 1) i.o. of the runnning shell
(kwrite &)
When you will close the terminal, the runnning job will then not been killed.
Remark: I'm far from being a linux expert so feel free to comment on this if you see problems with that way of doing things...
Offline
Another trick: if you put your command between parentheses, then the process will be child of init (process id 1) i.o. of the runnning shell
(kwrite &)
When you will close the terminal, the runnning job will then not been killed.
Great. This is something I really missed.
In order to really understand what happens. Is this caused by this behaviour (quoted from man bash)?
COMMAND EXECUTION ENVIRONMENT
...
Command substitution, commands grouped with parentheses, and asynchronous com‐
mands are invoked in a subshell environment that is a duplicate of the shell
environment, except that traps caught by the shell are reset to the values
that the shell inherited from its parent at invocation. Builtin commands that
are invoked as part of a pipeline are also executed in a subshell environment.
Changes made to the subshell environment cannot affect the shell's execution
environment.
Or is there another mechanism at work?
(Learning bash for half a century now. And still not grasped some very basics...
)
Edit:
Oops! I am not that old. Certainly it is (more than) half a decade only. ![]()
Last edited by bernarcher (2009-09-18 19:18:16)
To know or not to know ...
... the questions remain forever.
Offline
In order to really understand what happens. Is this caused by this behaviour (quoted from man bash)?
Yep, it's indeed the subshell stuff.
Cheers.
Offline