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
...
- 03-05-2011 #1Just 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 ...
- 03-05-2011 #2
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.
- 03-05-2011 #3Just 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:
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.Code:[brian@bmicek ~]$ sleep 10
When you tell your shell to put something in the background like this:
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.Code:[brian@bmicek ~]$ sleep 10 & [1] 22985
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:
Here is what ps shows:Code:[brian@bmicek ~]$ read & [1] 23095 [1]+ Stopped read
According to "man 1 ps", the 'T' means:Code:[brian@bmicek ~]$ ps -o pid,state -p 23095 PID S 23095 T
T Stopped, either by a job control signal or because it is being
traced.
- 03-06-2011 #4Just 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
GurpreetLast edited by gurpreet_bassan; 03-06-2011 at 09:34 AM.
- 03-06-2011 #5


Reply With Quote