İşletim Sistemleri (Bahar-2016) Hafta-10/1
Sinyallerin yakalanması
#include<iostream> #include<unistd.h> #include<signal.h> using namespace std; int i=0; void islem(int sinyal) { i++; if(sinyal==SIGINT) cout<<i<<" :: CTRL+C sinyali"<<endl; if(sinyal==SIGTERM) cout<<i<<" :: TERM sinyali"<<endl; } int main() { cout<<"PROC:"<<getpid()<<endl; while(true) { signal(SIGINT,&islem); signal(SIGTERM,&islem); } }