Find the answer to your Linux question:
Results 1 to 5 of 5
hi friends, i want to send a running process to background .. normal commands like sleep i can able to move easily to bg . # sleep 10 #Ctrl+z #bg ...
  1. #1
    Just Joined!
    Join Date
    Feb 2009
    Posts
    12

    moving a process to background using PID

    hi friends,

    i want to send a running process to background ..
    normal commands like sleep i can able to move easily to bg .
    # sleep 10
    #Ctrl+z
    #bg

    but how can i move a telnet window to background ...
    because Ctrl+z will be inputted to the telnetted bash ...

    is it possible to move a process to background using its PID ...

    please help me to slove this problem ..


    Thanks in advance ...

  2. #2
    Linux Newbie Nagarjuna's Avatar
    Join Date
    Feb 2011
    Posts
    122
    Hmm, if I'm understanding your situation correctly, you want to be able to telnet into a server and then put your telnet session into the background so you can return to your shell on the local system, and then bring the telnet session into the foreground when later needed, correct?

    If so, I'm afraid I do not know how one would put the telnet session into the background, since like you said, running any of the mentioned commands will be interpreted by the server you telnet into. I'm very curious my self if there is a way to reference the local system from a telnet session..

    Though I can't give you a definite answer, I can recommend a neat little program called 'screen', if your not already familiar with it. Screen allows you to have multiple terminal sessions in one terminal. So, you can telnet into a server and then create another screen for local system access. You can then switch between the two as needed. Think of it as tabbed browsing, but for terminals and without the graphical interface.

    Check it out, it's really cool. If you need any help with it just give me a shout, I'll be glad to assist.

  3. #3
    Just Joined!
    Join Date
    Jan 2011
    Location
    Fairfax, Virginia, USA
    Posts
    94

    moving a process to background using PID

    When you run a process normally like this:
    Code:
    [brian@bmicek ~]$ sleep 10
    your shell (bash?) most likely fork(2)s a new bash(1) shell then exec(2)s sleep(1) and finally wait(2)s for it to terminate.

    When you tell your shell to put something in the background like this:
    Code:
    [brian@bmicek ~]$ sleep 10 &
    [1] 22985
    then bash does all the above but doesn't wait(). The reason I'm saying this is because the background is usually an illusion presented by your shell and I'm not aware of a mechanism to externally tell any shell to put something in the background.

    There is more, when you fork() and exec() something, it inherits a lot of the features of its parent PIDs but only one process can read(2) from stdin at a time. This means if you put something in the background like a telnet client that read(2)s from stdin, the kernel will move it to a STOPPED state while it waits for its resource to free. Here is an example:
    Code:
    [brian@bmicek ~]$ read &
    [1] 23095
    [1]+  Stopped                 read
    Here is what ps shows:
    Code:
    [brian@bmicek ~]$ ps  -o pid,state -p 23095
      PID S
    23095 T
    According to "man 1 ps", the 'T' means:
    T Stopped, either by a job control signal or because it is being
    traced.

  4. #4
    Just Joined!
    Join Date
    Dec 2007
    Location
    Pune
    Posts
    2
    Hi

    To send a process into sleep, you just need to send the required signal as is the case when you kill it with "kill -9 <pid>".

    So in your case open another terminal find out the pid of the process and do:
    kill -19 <pid>
    This will move the process to background.

    HTH

    Gurpreet
    Last edited by gurpreet_bassan; 03-06-2011 at 09:34 AM.

  5. #5
    Just Joined! VirtualLinuxUser's Avatar
    Join Date
    Mar 2008
    Location
    Pietermaritzburg, KwaZulu Natal, South Africa
    Posts
    28
    I'd also suggest working with screen. Alternatively, you can run telnet in one of up to 7 different terminal sessions on one machine by pressing <Alt> + <Fx> (where x is a number from 1 to 7) I've never used telnet, so I don't know if that would work.
    This might also help you.

Posting Permissions

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