[Toybox] #563: cp ignores errors during write syscall and exits with success

Utsav Munendra utsavm at meta.com
Sun Sep 7 23:12:31 PDT 2025


Adding the link to PR:
https://github.com/landley/toybox/pull/567

________________________________
From: Utsav Munendra
Sent: Sunday, September 7, 2025 11:10 PM
To: toybox at lists.landley.net <toybox at lists.landley.net>
Subject: #563: cp ignores errors during write syscall and exits with success

Github PR: xsendfile_len() to exit with error if underlying write fails #567<http://xsendfile_len()%20to%20exit%20with%20error%20if%20underlying%20write%20fails%20#567>
Github Issue: cp ignores errors during write syscall and exits with success #563<https://github.com/landley/toybox/issues/563>

I have noticed that `cp` exits with success even when the underlying `write()` system call fails.
```
strace cp another.dat /mnt/vendor/syncboss/cal/
...
write(4, "n\r\261\314l\266\361\257\370\335\213T\321\257\370t!\243\343a0\204\202\33={l,\v>+w"..., 4096) = -1 ENOSPC (No space left on device)
close(3)                                = 0
close(4)                                = 0
madvise(0x7769610000, 28672, MADV_DONTNEED) = 0
exit_group(0)                           = ?
+++ exited with 0 +++
```

Attaching the patch which worked to resolve the issue for me. Looking to get it merged and or suggestions.

Best,
Utsav Munendra
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20250908/41618361/attachment-0001.htm>


More information about the Toybox mailing list