diff --git a/man/systemd.exec.xml b/man/systemd.exec.xml index 9adb6a298e..663b15fa60 100644 --- a/man/systemd.exec.xml +++ b/man/systemd.exec.xml @@ -2430,8 +2430,19 @@ SystemCallErrorNumber=EPERM is similar to - above, but it truncates the file when opening it. - + above, but it truncates the file when opening + it. For units with multiple command lines, e.g. Type=oneshot services with + multiple ExecStart=, or services with ExecCondition=, + ExecStartPre= or ExecStartPost=, the output file is reopened + and therefore re-truncated for each command line. If the output file is truncated while another + process still has the file open, e.g. by an ExecReload= running concurrently with + an ExecStart=, and the other process continues writing to the file without + adjusting its offset, then the space between the file pointers of the two processes may be filled + with NUL bytes, producing a sparse file. Thus, + is typically only useful for units where + only one process runs at a time, such as services with a single ExecStart= and no + ExecStartPost=, ExecReload=, ExecStop= or + similar. connects standard output to a socket acquired via socket activation. The semantics are similar to the same option of StandardInput=, see above. diff --git a/test/test-execute/exec-standardoutput-truncate.service b/test/test-execute/exec-standardoutput-truncate.service index 7a12a06923..4b4bb87b75 100644 --- a/test/test-execute/exec-standardoutput-truncate.service +++ b/test/test-execute/exec-standardoutput-truncate.service @@ -8,6 +8,5 @@ StandardInput=data StandardInputText=hi StandardOutput=truncate:/tmp/test-exec-standardoutput-output StandardError=null -ExecStart=cat -ExecStartPost=cmp /tmp/test-exec-standardoutput-output /tmp/test-exec-standardoutput-expected +ExecStart=sh -c 'cat && cmp /tmp/test-exec-standardoutput-output /tmp/test-exec-standardoutput-expected' Type=oneshot