Jump to content

Unix Advanced: Difference between revisions

zOMG MISSING COMMA
mNo edit summary
(zOMG MISSING COMMA)
 
(7 intermediate revisions by 2 users not shown)
Line 4: Line 4:
Processes
Processes


A process is a program that runs when you execute a command in UNIX. You can have more than one process running at a time, which obviously means you can have more than one program running at a time. "How can this be Conor!?" you shout at me. I cover my ears and respond that you can run some programs in the background or you can put some programs on hold while you do something else equally crazy. And here's how you do all this magic UNIX stuff!
A process is a program that runs when you execute a command in UNIX. You can have more than one process running at a time, which obviously means you can have more than one program running at a time. "How can this be, Conor!?" you shout at me. I cover my ears and respond that you can run some programs in the background or you can put some programs on hold while you do something else equally crazy. And here's how you do all this magic UNIX stuff!


== Suspending a Process ==
== Suspending a Process ==
Line 67: Line 67:
  cokane 68730  0.0  0.3  1620 1324  pi  T    5:36PM  0:00.02 slrn
  cokane 68730  0.0  0.3  1620 1324  pi  T    5:36PM  0:00.02 slrn
  cokane 68741  0.0  0.0  388  220  pi  R+    5:36PM  0:00.00 ps -u
  cokane 68741  0.0  0.0  388  220  pi  R+    5:36PM  0:00.00 ps -u
  prompt$ ps
  prompt$ ps
   PID  TT  STAT      TIME COMMAND
   PID  TT  STAT      TIME COMMAND
Line 72: Line 73:
  68730  pi  T      0:00.02 slrn
  68730  pi  T      0:00.02 slrn
  68749  pi  R+    0:00.00 ps
  68749  pi  R+    0:00.00 ps
  prompt$ kill -SIGKILL 68730
  prompt$ kill -SIGKILL 68730
  [1]  + killed    slrn
  [1]  + killed    slrn
  prompt$
  prompt$


Line 89: Line 92:


You see in the above example that when a process gets killed (or finishes itself), the shell will print that the process has finished or has been killed. In the above example you can see that it shows the job number in square brackets, then the reason the process returned (that it was killed) and the name of the process.
You see in the above example that when a process gets killed (or finishes itself), the shell will print that the process has finished or has been killed. In the above example you can see that it shows the job number in square brackets, then the reason the process returned (that it was killed) and the name of the process.
Signals
 
== Signals ==


Now I will (attempt to) explain signals in UNIX...
Now I will (attempt to) explain signals in UNIX...
Line 97: Line 101:
Below I will list some of the most common signals and what they're used for. I reserve the right to be very wrong about some of them :o)
Below I will list some of the most common signals and what they're used for. I reserve the right to be very wrong about some of them :o)


*SIGKILL        As explained already... to kill a process
*SIGKILL         
As explained already... to kill a process


*SIGTERM         Similar to SIGKILL but it won't kill the process straight away.  
*SIGTERM          
Similar to SIGKILL but it won't kill the process straight away.  


*SIGSTOP         This is the signal which suspends a process..
*SIGSTOP          
This is the signal which suspends a process..


*SIGSTP Similar to SIGSTOP, this is the signal that pressing
*SIGSTP
CTRL + Z sends.
Similar to SIGSTOP, this is the signal that pressing CTRL + Z sends.


*SIGCONT         The signal sent to continue a suspended process.
*SIGCONT          
The signal sent to continue a suspended process.


*SIGTTOU         This occurs when a process running in the background attempts
*SIGTTOU          
to write to the terminal. The process gets suspended.
This occurs when a process running in the background attempts to write to the terminal. The process gets suspended.


*SIGTTIN As above except occurs when process tries to read input
*SIGTTIN
from terminal
As above except occurs when process tries to read input from terminal.


*SIGHUP The "hang up" signal, nowadays sending this to a process
*SIGHUP
will cause the process (if it's a daemon) to re-read its  
The "hang up" signal, nowadays sending this to a process will cause the process (if it's a daemon) to re-read its configuration files without you having to restart the process itself.
configuration files without you having to restart the process  
itself.




Line 127: Line 133:
There ends my sucky sig explanation ;o)
There ends my sucky sig explanation ;o)


Please note: This explanation of ps refers to the GNU version used in BSD and Linux: we are now on Solaris so your ps commands will be different. Check the man page for details. In the meantime, use /usr/ucb/ps to run the commands shown above.
Hopefully you've found this tutorial a bit helpful and have maybe learnt something as well from it as well.


Hopefully you've found this tutorial a bit helpful and have maybe learnt something as well from it as well.
== Links ==
 
[[Unix Intro]] - basic Unix commands, just in case you forgot them or something...
 
[[Helpdesk]] - more tutorials!
 
[[Category:Helpdesk]]