01-27-2012
problem with restarted I/O system calls
Greetings.
Suppose I have a UNIX OS with automatic-restart (by default) of interrupted system calls,
or I use sigaction() with SA_RESTART flag.
If I am in the middle of a read(fd1, buf1, MAXSIZE) or a write(fd2, buf2, MAXSIZE),
and I am interrupted by a signal, then the system will automatically restart my system calls.
The problem is that if the read() succedded with reading n1 bytes, then the file-offset of fd1
will be updated by n1 bytes, but the "offset" in buf1 buffer will not be.
So, when the kernel restarts (automatically) the read() system call, then it is very probable
that my buf1 buffer will be overwritten.
What is the solution to this problem ? (To "save" the content of buf1, before the interrupted
system call is restarted.)
Thank you.
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
What does the system call "dup" do?
What is the difference between dup and dup2
I have a fair idea of what it does but I am confused when its coming down to the exact details...
Please help me!:confused: (2 Replies)
Discussion started by: clickonline1
2 Replies
2. UNIX for Dummies Questions & Answers
Which system calls are made for operations cp and mv (2 Replies)
Discussion started by: gaurava99
2 Replies
3. UNIX for Dummies Questions & Answers
open, creat, read, write, lseek and close
Are they all primitive?
:confused:
*Another Question: is there a different between a system call, and an i/o system call? (2 Replies)
Discussion started by: PlunderBunny
2 Replies
4. Solaris
where can i find the differences in System calls between solaris and aix?
also is it possible to find a comprehensive list of them? (1 Reply)
Discussion started by: TECHRAMESH
1 Replies
5. UNIX Desktop Questions & Answers
Hi,
I'm new to UNIX system calls. Can someone share your knowledge as to how exactly system calls should be executed?
Can they be typed like commands such as mkdir on the terminal itself? Also, are there any websites which will show me an example of the output to expect when a system call like... (1 Reply)
Discussion started by: ilavenil
1 Replies
6. Programming
why user is not able to switch from user to kernel mode by writing the function whose code is identical to system call. (1 Reply)
Discussion started by: joshighanshyam
1 Replies
7. BSD
what is the functions and relationship between fork,exec,wait system calls
as i am a beginer just want the fundamentals. (1 Reply)
Discussion started by: sangramdas
1 Replies
8. UNIX for Dummies Questions & Answers
Hi all,
I am new here .
I want to know about system call in detail.
As system calls are also function .How system identifies it.:) (2 Replies)
Discussion started by: vishwasrao
2 Replies
9. UNIX for Dummies Questions & Answers
Hello,
how would i be able to call ps in C programming?
thanks,
---------- Post updated at 01:39 AM ---------- Previous update was at 01:31 AM ----------
here's the complete system call, ps -o pid -p %d, getpit() (2 Replies)
Discussion started by: l flipboi l
2 Replies
10. UNIX for Dummies Questions & Answers
One of our Host server got restarted unexpectedly and all we got is this.
Not able to guess the root cause behind this .Please help.
Before restart
Oct 17 19:56:06 SERVER1 kernel: suspend: event channel 75
Oct 17 19:56:10 SERVER1 smartd: smartd version 5.38 Copyright (C) 2002-8 Bruce... (3 Replies)
Discussion started by: pinga123
3 Replies
LEARN ABOUT OPENDARWIN
siginterrupt
SIGINTERRUPT(3) Linux Programmer's Manual SIGINTERRUPT(3)
NAME
siginterrupt - allow signals to interrupt system calls
SYNOPSIS
#include <signal.h>
int siginterrupt(int sig, int flag);
Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
siginterrupt():
_XOPEN_SOURCE >= 500
|| /* Since glibc 2.12: */ _POSIX_C_SOURCE >= 200809L
|| /* Glibc versions <= 2.19: */ _BSD_SOURCE
DESCRIPTION
The siginterrupt() function changes the restart behavior when a system call is interrupted by the signal sig. If the flag argument is
false (0), then system calls will be restarted if interrupted by the specified signal sig. This is the default behavior in Linux.
If the flag argument is true (1) and no data has been transferred, then a system call interrupted by the signal sig will return -1 and
errno will be set to EINTR.
If the flag argument is true (1) and data transfer has started, then the system call will be interrupted and will return the actual amount
of data transferred.
RETURN VALUE
The siginterrupt() function returns 0 on success. It returns -1 if the signal number sig is invalid, with errno set to indicate the cause
of the error.
ERRORS
EINVAL The specified signal number is invalid.
ATTRIBUTES
For an explanation of the terms used in this section, see attributes(7).
+---------------+---------------+-------------------------+
|Interface | Attribute | Value |
+---------------+---------------+-------------------------+
|siginterrupt() | Thread safety | MT-Unsafe const:sigintr |
+---------------+---------------+-------------------------+
CONFORMING TO
4.3BSD, POSIX.1-2001. POSIX.1-2008 marks siginterrupt() as obsolete, recommending the use of sigaction(2) with the SA_RESTART flag
instead.
SEE ALSO
signal(2)
COLOPHON
This page is part of release 4.15 of the Linux man-pages project. A description of the project, information about reporting bugs, and the
latest version of this page, can be found at https://www.kernel.org/doc/man-pages/.
2016-03-15 SIGINTERRUPT(3)