From 9145242980ca25f54b5ae1fd0723964bad79dfb7 Mon Sep 17 00:00:00 2001 From: Zhang Boyang Date: Sat, 3 May 2025 15:49:12 +0800 Subject: [PATCH 1/2] Remove unnecessary mention of os.fsync() from os.exec*() docs Before a process is replaced by os.exec*(), userspace buffers usually need to be flushed. However, it is not necessary to flush kernel buffers to disk using os.fsync(). Flushing userspace buffer to kernel, and flushing kernel buffer to disk, are two different things. In addition, os.fsync() is not applicable to pipes or sockets. This patch removes this confusing information. --- Doc/library/os.rst | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Doc/library/os.rst b/Doc/library/os.rst index 54a5d3b98e8662..f634aaa4886322 100644 --- a/Doc/library/os.rst +++ b/Doc/library/os.rst @@ -4318,11 +4318,10 @@ to be ignored. and will have the same process id as the caller. Errors will be reported as :exc:`OSError` exceptions. - The current process is replaced immediately. Open file objects and - descriptors are not flushed, so if there may be data buffered - on these open files, you should flush them using - :func:`sys.stdout.flush` or :func:`os.fsync` before calling an - :func:`exec\* ` function. + The current process is replaced immediately. Open file objects are not + flushed, so if there may be data buffered on these open files, you should + flush them using :meth:`~io.IOBase.flush`, e.g. ``sys.stdout.flush()``, + before calling an :func:`exec\* ` function. The "l" and "v" variants of the :func:`exec\* ` functions differ in how command-line arguments are passed. The "l" variants are perhaps the easiest From 76e6753b75453e7abeeb1e80b8a999078ab62264 Mon Sep 17 00:00:00 2001 From: Zhang Boyang Date: Mon, 12 May 2025 19:49:21 +0900 Subject: [PATCH 2/2] Use `:meth:` for `sys.stdout.flush` Co-authored-by: Peter Bierma --- Doc/library/os.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/os.rst b/Doc/library/os.rst index f634aaa4886322..7d22fa9924fb40 100644 --- a/Doc/library/os.rst +++ b/Doc/library/os.rst @@ -4320,7 +4320,7 @@ to be ignored. The current process is replaced immediately. Open file objects are not flushed, so if there may be data buffered on these open files, you should - flush them using :meth:`~io.IOBase.flush`, e.g. ``sys.stdout.flush()``, + flush them using :meth:`~io.IOBase.flush`, e.g. :meth:`sys.stdout.flush`, before calling an :func:`exec\* ` function. The "l" and "v" variants of the :func:`exec\* ` functions differ in how