Skip to content

Commit 88e3bae

Browse files
committed
add comment as to dump_file() performs the seeking
1 parent e8c978e commit 88e3bae

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

file-locking/fcntl-locking.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,13 @@ dump_file(char *filename, bool locking)
145145
if (locking)
146146
lockr(fd, &fl);
147147

148+
/*
149+
* The file size is not hard-coded here so that one can
150+
* see the contents of the file before it is fully written.
151+
* This can totally happen, the parent can get to calling
152+
* dump_file() because any of the children finish the complete
153+
* write.
154+
*/
148155
(void) lseek(fd, SEEK_SET, 0);
149156
memset(buf, 0, sizeof (buf));
150157
n = read(fd, buf, sizeof (buf));

0 commit comments

Comments
 (0)