1
0
Fork 0
mirror of https://repo.or.cz/socat.git synced 2025-07-14 15:23:24 +00:00

handle partial write()'s without data loss

This commit is contained in:
Gerhard Rieger 2011-10-09 09:18:31 +02:00
parent 3881c794a7
commit 6a8f6c0734
9 changed files with 114 additions and 47 deletions

View file

@ -1,5 +1,5 @@
/* source: xiolockfile.c */
/* Copyright Gerhard Rieger 2005-2006 */
/* Copyright Gerhard Rieger 2005-2011 */
/* Published under the GNU General Public License V.2, see file COPYING */
/* this file contains socats explicit locking mechanisms */
@ -52,7 +52,10 @@ int xiogetlock(const char *lockfile) {
pid = Getpid();
bytes = sprintf(pidbuf, F_pid, pid);
Write(fd, pidbuf, bytes);
if (writefull(fd, pidbuf, bytes) < 0) {
Error4("write(%d, %p, "F_Zu"): %s", fd, pidbuf, bytes, strerror(errno));
return -1;
}
Close(fd);
/* Chmod(lockfile, 0600); */