BUT2/SCR/SCR2/TP04/section_critique.c

35 lines
438 B
C
Raw Normal View History

2023-10-12 16:39:49 +02:00
#include<unistd.h>
#include<stdio.h>
#include<stdlib.h>
#include<signal.h>
#include<stdint.h>
#include<assert.h>
#include "helpers.h"
int x=2,y=3;
int swap(int *x,int *y)
{
int tmp=*x;
*x=*y;
*y=tmp;
}
void sig_handler(int signo)
{
switch(signo){
case SIGQUIT :
printf("x=%d y=%d\n",x,y);
break;
}
}
int main(int argc,char * argv[])
{
assert(set_signal_handler(SIGQUIT,sig_handler)==0);
while(1){
swap(&x,&y);
}
}