السلام عليكم ورحمة الله وبركاته
المطلوب كود يرسل إشارة STOP من العملية لنفسها
استخدمت الدالة ()kill ولكني أحس مكانها مو صح !
هذا الكود ياليت تساعدوني
مستعجلة جداً :/
#include<stdio.h>
#include <unistd.h> /* standard unix functions, like getpid() */
#include <sys/types.h> /* various type definitions, like pid_t */
#include <signal.h> /* signal name macros, and the kill() prototype */
/* first, find my own process ID */
pid_t my_pid = getpid();
/* now that i got my PID, send myself the STOP signal. */
kill(my_pid, SIGSTOP);
void sig_handler(int signo)
{
printf("received SIGSTOP\n");
}
int main(void)
{
if (signal(SIGSTOP, sig_handler) == SIG_ERR)
printf("\ncan't catch SIGSTOP\n");
// A long long wait so that we can easily issue a signal to this process
while(1)
sleep(1);
return 0;
}