Re: pipe writes, ERESTARTSYS and SA_RESTART

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

Le 04/08/2022 à 20:01, Viacheslav Biriukov a écrit :

But what I can't understand is how and where the kernel modifies the arguments of the write system call and where it collects the return values of all these restarts, thus the userspace caller ultimately sees the correct number of written bytes.

With strace I can see all that retries, for example:

write(1, ""..., 33554431)               = 65536
write(1, ""..., 33488895)               = ? ERESTARTSYS (To be restarted if SA_RESTART is set) write(1, ""..., 33488895)               = ? ERESTARTSYS (To be restarted if SA_RESTART is set) write(1, ""..., 33488895)               = ? ERESTARTSYS (To be restarted if SA_RESTART is set)
write(1, ""..., 33488895)               = 33488895

Here there were 4 restarts (I sent 4 signals), 3 of them returned ERESTARTSYS and 2 were able to write to the pipe. Also for restarts strace shows the correct 3rd argument, which is decrementing.

The caller in the userspace in the end sees that it was able to write 65536+33488895 bytes. Which is correct and what the man 7 pipe describes.

My question is how and where it does that. I tried to dig in the kernel source code but can't find the place where this tracking occurs.


It doesn't. SA_RESTART is only meant to retry syscall that would have returned EINTR.

In such case, there's no tracking to do, because nothing was actually written, so the syscall can be restarted with the same parameters.


Regards.

--

Yann Droneaud

OPTEYA



_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies




[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]

  Powered by Linux