Controlling Processes Periodic Processes Wee San Lee weesancs
- Slides: 15
Controlling Processes & Periodic Processes Wee. San Lee <weesan@cs. ucr. edu> http: //www. cs. ucr. edu/~weesan/cs 183/
Roadmap n n n n n What is a process? What is a setuid process? How to create a process? Signals How to send signals to the processes? Process States Niceness Monitor Processes Periodic Processes Q&A
What is a process? n n A running program Information of a process q q q q PID PPID UID & EUID (used for access permission) GID & EGID (used for access permission) Status Niceness or nice value …
What is a setuid process? n A regular process q n A setuid process q n EUID == UID of the user who runs the command/script EUID == the owner UID of the setuid command/script How to find setuid programs? q $ find /bin -perm -4000 | xargs ls -l n n n -rwsr-xr-x 1 root 57908 Nov 30 14: 35 /bin/mount -rwsr-xr-x 1 root 35864 Mar 14 2007 /bin/ping -rwsr-xr-x 1 root 31244 Mar 14 2007 /bin/ping 6 -rwsr-xr-x 1 root 24060 Mar 21 2007 /bin/su -rwsr-xr-x 1 root 38840 Nov 30 14: 35 /bin/umount
How to create a process? n $ emacs // Bash switch (fork()) { case -1: // Error break; case 0: // Child execv("emacs", . . . ); break; default: // Parent wait(…); break; } // Bash clone switch (fork()) { case -1: // Error break; case 0: // Child execv("emacs", …); break; default: // Parent wait(…); break; }
Signals n n Process-level interrupt requests ~30 signals q n $ kill -l Can be caught or trapped by a process q In Bash, we do: n n trap ‘done 2(); exit’ 0 1 2 3 15 Can be blocked or ignored
Signals (cont) n Common signals q 1 HUP q 2 INT n q 3 QUIT n q q q Core dumping 9 KILL 15 TERM STOP TSTP n q Ctrl-C Ctrl-Z CONT USR 1 USR 2
How to send signals to the processes? n $ kill [-signal] pid q q Default signal is TERM or 15 $ ps auxw | grep emacs n q n weesan 857 0. 0 13312 7952 pts/5 S Apr 15 0: 05 emacs $ kill -9 857 $ killall [-signal] process_name q $ killall -9 emacs
Process States n Runnable (R) q n Sleeping (S) q n Get no CPU time until receiving a signal Zombie (Z) q q n Ready to be executed Exited process whose status hasn’t been collected Display as <defunct> on ps, Stopped (T) q Process stopped by STOP or TSTP signal
Niceness n n -20 to +19 A high nice value means a low priority Inherited from the parent Can increase but not decrease q n Except for root For example: q q $ nice -n 1 program $ renice 1 pid
Monitor Processes n ps q A tool for monitoring processes, eg. n n n $ ps auxw | less $ ps laxw | less $ ps auxw | awk -F' ' '{ print $1, $2, $10; }' q q n weesan 560 2: 28 weesan 563 0: 00 top q q q A good tool to display CPU usage $ top -n 1
Monitor Processes (cont) n strace q q n lsof q q q n Show every system call and signal a process receives $ strace -p pid List open files $ lsof -u userid $ lsof -p pid uptime q Display the current time, how long the system has been up, # of current users, average system load for the pass 1, 5 and 15 mins
Monitor Processes (cont) Runaway processes n q Processes that consume excessive amounts of a system resource, such as CPU time or disk space How to approach them? n 1. 2. 3. 4. Use ps, top, strace, lsof to locate them renice them Stop them by sending STOP signal and resume later by CONT signal kill them
Periodic Processes n cron daemon A daemon that run jobs periodically Crontab (/etc/crontab, /etc/cron. */, /var/spool/cron/) q $ crontab -l q $ crontab -e q n n Format q q Min Hour Day Month Weeday Command 10 23 * * mon-fri /home/weesan/backup/home. sh 30 23 * * fri /home/weesan/backup/import. sh 0 */1 * * * /usr/bin/rdate -s time. nist. gov
Reference n LAH q q Ch 4: Controlling Processes Ch 8: Periodic Processes
- Lee wee sun
- Markov decision process
- Jaggers menu calories
- Radius trend periodic table
- 15/999 mass street periodic table, o 8
- Chapter 6 periodic table
- Chapter 6 the periodic table
- The periodic table and periodic law chapter 6
- Concurrent in os
- Chee wee liu
- Peewee egg
- Zechariah was a wee little man
- Chee wee liu
- Ta wee
- Rose wee
- Wee fim