Reputation: 196
I have more then three timer running from main as given below, and I have defined one message queue in main section. My timer's expiration time in 10(max). Why, when timer expires "msgrcv" gives error like "Interrupted system call"?
timer_t timer1 = create_timer(TT_SIGUSR1);
install_sighandler(TT_SIGUSR1, signal_handler);
set_timer(timer1, TIME_INTERVAL_1);
-
-
-
flag = IPC_CREAT | 0666;
key = 1234;
msgqid = msgget(key,flag);
printf("msgqid = %d\n",msgqid);
while (1)
{
msgsz = msgrcv(msgqid, &sendMsg, sizeof(sendMsg), 0,0);
perror("prashant");
sleep(1);
}
return 0;
Upvotes: 0
Views: 6448
Reputation: 182649
Because you probably setup your timer to send you a signal when it expires. Receiving a signal while blocked on certain system calls will make said system calls fail with errno = EINTR
.
The msgrcv() function shall fail if:
[EINTR]
The msgrcv() function was interrupted by a signal.
Upvotes: 2