Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Suppose I am downloading file from internet with wget.

Now if I press CTRL + Z then it says process stopped.

Now I want to know that will it gets killed automatically or it will stay as it is. Will it consume any memory

share|improve this question

4 Answers 4

up vote 3 down vote accepted

It will stay. ctrl + Z sends SIGTSTP signal to process not SIGQUIT or SIGKILL. If you would like to kill process then use ctrl + C or kill your stopped process with kill command. In some shells it is just kill %.

share|improve this answer
    
thanks for that . also if i am using wget from putty terminal and i close the putty . will file stll gets downloaded on server –  user105919 Nov 25 '11 at 7:36
    
If you close your terminal then it sends SIGHUP to all its child processes. Normally processes die after that but not wget. It redirects its output to wget-log and continues running. Of course not if it is already stopped by ctrl + Z –  Cougar Nov 25 '11 at 7:50
    
thanks for that . I didn't knew wget keeps running –  user105919 Nov 25 '11 at 7:56
2  
Isn't it SIGTSTP? –  Daniel Beck Nov 25 '11 at 8:29
2  
Ctrl+Z sends SIGTSTP(TSTP for tty Stop). Process can ignore SIGTSTP, but process must stop when SIGSTOP is sent. –  Sachin Divekar Nov 25 '11 at 10:25

By pressing ctrl + z, you only suspend/pause the process. In this case, the process stays alive and consumes memory. To kill the process, use ctrl + c or the kill command.

share|improve this answer

Ctrl+Z suspends (pauses) the process and prints job number in form [1]+ Stopped procname

You can resume and bring the process to foreground using fg 1, where 1 is the number that was printed to you.

Or you can resume it in background with bg 1, so that it will keep running while you continue working in the shell. The process will keep running even if you exit the shell. You can achieve the same effect by appending & to the end of the command line when starting the process, e.g.

wget http://www.example.com &
share|improve this answer
    
I want to know that if prcess is running in foreground and i close putty terminal without putting in background , then will it keep running on server –  user105919 Nov 25 '11 at 7:51
    
@user105919 It will receive SIGHUP, and will be unsuspended before, so it can receive the signal. How it responds to that depends on the program. Look into disown and nohup. –  Daniel Beck Nov 25 '11 at 8:30
    
You can have multiple suspened (paused) processes, so to list them and their current status one should use jobs command. –  lik Nov 26 '11 at 1:38

Even if the process does get killed, Linux will still keep it in memory. 99% of machines have more memory than they can actually use 99% of the time, so Linux keeps the program in memory on the chance that it will be run again soon. If it is, that saves the OS the trouble of loading the program from disk. If it's not, no harm done, the memory can be made free when needed.

If the process is not killed, it can still be ejected from memory. Linux knows that it can load the program back in from disk. So it doesn't have to waste memory, if memory is precious, holding data that's not actually being currently accessed.

So whether or not it uses up memory has nothing to do with whether the process terminates or not. Linux decides whether to keep things in memory based on recency of use, and either way it won't be being used.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.