Find the answer to your Linux question:
Results 1 to 6 of 6
Hi, I just wonder how can I send a running process to background. But I want to do this from another terminal, thus I'm not asking for 'Ctrl+Z and bg' ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jun 2006
    Posts
    3

    Sending a running process to background


    Hi,
    I just wonder how can I send a running process to background. But I want to do this from another terminal, thus I'm not asking for 'Ctrl+Z and bg' sequence. Today I encountered that problem. I was running a process in a konsole [KDE]. After some time KDE crashed, the program was still running on that konsole however I've no way to do 'Ctrl+Z' stuff - somehow konsole didn't get the keyboard input. In such a case, is there a way to open another tty and send that process to background? Thanx in advance..

  2. #2
    Linux User
    Join Date
    Jun 2006
    Posts
    311
    Hi iyacp,
    If you know the process ID of the process you want to run in background from another terminal, then do the following : -

    $ kill -20 PID
    To suspend that particular process and,
    $ kill -18 PID
    to resume the supended process.

    There is no difference between this and using 'bg' after a Ctrl + Z in the terminal where the process is running, except that you can do the same using a different terminal.

    With Regards,
    Thinker

  3. #3
    Just Joined!
    Join Date
    Jun 2006
    Posts
    3
    Hi Thinker,
    Thanx for the reply. That'd be really helpful for me Now I've another question - even I don't need to use the solution now. Since my KDE was crashed I needed to restart KDE. However during restart operation the konsole which my process is running on will die too, thus the suspended process too. Is there a way to rescue that process?

  4. #4
    Linux User
    Join Date
    Jun 2006
    Posts
    311

    Fix the Problem

    Hi iyacp,
    Why not try to fix the problem that you have with KDE, instead of trying to rescue the process?

    However during restart operation the konsole which my process is running on will die too, thus the suspended process too. Is there a way to rescue that process?
    What is the point in rescuing a process when you are actually restarting the machine itself?

    With Regards,
    Thinker

  5. #5
    Just Joined!
    Join Date
    Jun 2006
    Posts
    3
    Hi again,
    First of all I've to state that currently I've no such problem since I've already killed KDE and my process But I'm trying to learn how to act in such a situation, if I encounter again. When KDE crashed I was unable to use keyboard with X. And another point why I couldn't try to fix KDE was I didn't know what was the exact reason and what was the problem. The only thing i got was a crashed KDE, no keyboard on X - I was able to use them on another tty with no X - and a running process - which was running for four days. What I did was I restarted KDE not the machine itself. And I got a working KDE. But my process was died. Anyway now I'm using screen, but curious about the solution, if are there any Thanx for the help

  6. #6
    Just Joined!
    Join Date
    Jun 2004
    Location
    Portugal
    Posts
    47
    You've to detach your process from the konsole process, so that it isn't terminated when konsole is.

    I know two ways to do this (probably there are more):

    Method 1:
    - start the process from the konsole
    - put it the background with Ctrl-Z and 'bg 1'.
    - tell the shell to detach the process with the command 'disown -a'

    Method 2:
    - start the process with nohup (ie. write the command 'nohup processname' instead of 'processname'. See 'man nohup' for an explanation.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •