Unix Programming - Interrupted System Call

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > May 2004 > Interrupted System Call





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Interrupted System Call
Xarky

2004-05-14, 12:49 pm

Hi,
I have the following program, using message queues. As a message is
received it is forked, so that execution occurs on another process.
Some operations (mainly file operations) that are occuring on the
other processes may take a long time.

My problem is that as that as a new message is arrived(while another
process is executing), an error is being given and the error set in
errno is Interrupted System Call.

I think the problem is with EINTR. Can someone tell exactly how to
fix it in my program pls, so that it would not give any more problems
hopefully.


Thanks in Advance

/// Code

while (1)
{
if (msgrcv (msgid, &data, length, 1, 0) == -1)
{
remove_MSG_IPC();
// Interrupted System Call is being given here
error_msg(); // gives the error set by errno and exits
} // end if

pid = fork();
if (pid == -1)
error_msg();

else if (pid == 0) // child stuff - handling request of client
handling_Client_Request(data, length);

// parent will wait for another message and create a new process for
it
} // end while loop
Barry Margolin

2004-05-14, 1:35 pm

In article <bc42e1a.0405140727.302da002@posting.google.com>,
bernardpace@yahoo.com (Xarky) wrote:

> Hi,
> I have the following program, using message queues. As a message is
> received it is forked, so that execution occurs on another process.
> Some operations (mainly file operations) that are occuring on the
> other processes may take a long time.
>
> My problem is that as that as a new message is arrived(while another
> process is executing), an error is being given and the error set in
> errno is Interrupted System Call.
>
> I think the problem is with EINTR. Can someone tell exactly how to
> fix it in my program pls, so that it would not give any more problems
> hopefully.


Most of the time, if a system call returns an error with errno==EINTR,
you should just retry the system call.

Some system calls can also automatically restart themselves, if you've
used sigaction() to specify the SA_RESTART option for the signal.

--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com