Sponsored Content
Top Forums UNIX for Advanced & Expert Users problem with restarted I/O system calls Post 302593584 by aigoia on Friday 27th of January 2012 12:00:49 PM
Old 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

System Calls

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

System calls for cp and mv

Which system calls are made for operations cp and mv (2 Replies)
Discussion started by: gaurava99
2 Replies

3. UNIX for Dummies Questions & Answers

System calls?

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

System calls ?

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

Using system calls

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

System calls

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

system calls

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

About system calls.

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

system calls in C

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

System got restarted unexpectedly

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
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)
All times are GMT -4. The time now is 05:26 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy