[issue6394] getppid support in os module on Windows
Jon Anglin jang...@fortresgrand.com added the comment: Here is a unit test for os.getppid on Windows. The test_os.diff file is the diff of the Lib/test/test.os.py file from the py3k svn branch. -- Added file: http://bugs.python.org/file18784/test_os.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6394 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6394] getppid support in os module on Windows
Jon Anglin jang...@fortresgrand.com added the comment: I have uploaded a new diff file (from the py3k svn trunk) that has all of the changes in Doc/library/os.rst, Modules/posixmodule.c, and Lib/test/test_os.py. It is called 6394.diff. Let me know if I can do anything else to make this happen. -- Added file: http://bugs.python.org/file18785/6394.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6394 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6394] getppid support in os module on Windows
Amaury Forgeot d'Arc amaur...@gmail.com added the comment: I'm currently working on it. I'll certainly commit it shortly with a few changes: - no need to say that a function fails with WindowsError, at least in the docstring. - return error sooner to reduce indentation. - in tests, use subprocess instead of multiprocessing. - other minor formatting nits. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6394 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6394] getppid support in os module on Windows
Amaury Forgeot d'Arc amaur...@gmail.com added the comment: Committed r84601. Thanks for the patch and your perseverance! -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6394 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6394] getppid support in os module on Windows
Changes by Amaury Forgeot d'Arc amaur...@gmail.com: -- resolution: - fixed stage: patch review - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6394 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6394] getppid support in os module on Windows
Changes by Antoine Pitrou pit...@free.fr: -- nosy: +brian.curtin, tim.golden stage: - patch review versions: +Python 3.2 -Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6394 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6394] getppid support in os module on Windows
Amaury Forgeot d'Arc amaur...@gmail.com added the comment: First, I checked that the API does exist on Window 2000. And python does not have any never fail guarantee, specially in low memory conditions. Then, some remarks: - If Process32First or Process32Next fail for any reason, return win32_error(...) is called, but the GetLastError function won't find the cause because CloseHandle will clear it. - It would be nice to add a comment like if the loop ends and our pid was not found, GetLastError() will return ERROR_NO_MORE_FILES. This is an error anyway, so let's raise this. - A unit test is necessary: it could use a subprocess and compare getpid() with the child's getppid(). - The documentation should state what happens when the parent process exits. Is the ppid reset to zero? Is it possible to have another new process with the same ppid? -- nosy: +amaury.forgeotdarc ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6394 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6394] getppid support in os module on Windows
Jon Anglin jang...@fortresgrand.com added the comment: Just some information, on Windows: - process ids are re-used. - parent process id is set at process creation time and never updated. (Windows Internal 4th Ed. by Russinovich and Solomon). Thus, I would say that a long running process can not rely on the value of its parent process id. The parent may not be running, or the process id may have been re-used and the process with that id may not be in fact the actual parent. Having said that, I don't know the algorithm that Windows uses for process ids, so collisions may be rare (or not). -Do these same issues exist on Unix systems? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6394 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6394] getppid support in os module on Windows
Amaury Forgeot d'Arc amaur...@gmail.com added the comment: Do these same issues exist on Unix systems? No. When the parent exits, the child process is attached to the 'init' process and getppid() returns 1. And collisions are not rare at all. Actually it seems that you get the same pid if you close and restart a program quickly. That's why Windows apps prefer dealing with process handles instead of process ids -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6394 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6394] getppid support in os module on Windows
Jon Anglin jang...@fortresgrand.com added the comment: I didn't raise an exception because the Unix version never fails (or raises) so I thought to maintain compatibility I would always return a value. Do you advise that I should change it? As for the tabs... This entire process is new to me and I am learning, it was just a mistake. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6394 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6394] getppid support in os module on Windows
New submission from Jon Anglin jang...@fortresgrand.com: Implements getppid in the os module on Windows systems. The getppid function was only available on Unix like systems, this diff patch brings this functionality to Windows systems. This function will return the parent process Id, upon error it will return -1. This differs from the Unix implementation that never fails. Due to the way Windows returns the parent process Id, a never fail guarantee can not be made. It should only fail in low memory conditions. This patch is on the latest svn trunk ( http://svn.python.org/projects/python/trunk). This implementation should port to any python version (older or newer). I have personally tested it against Python 2.5.4, 2.6.2, 3.1, and the aforementioned svn trunk. -- components: Library (Lib) files: mydiffs.diff keywords: patch messages: 89981 nosy: janglin severity: normal status: open title: getppid support in os module on Windows type: feature request versions: Python 2.7 Added file: http://bugs.python.org/file14419/mydiffs.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6394 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6394] getppid support in os module on Windows
Antoine Pitrou pit...@free.fr added the comment: I'm not qualified to comment on Windows-specific code, but two things: - you should raise an appropriate exception on failure, not return -1 - the file is intended with tabs, not spaces -- nosy: +pitrou ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6394 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6394] getppid support in os module on Windows
Jon Anglin jang...@fortresgrand.com added the comment: Implements getppid in the os module on Windows systems. The getppid function was only available on Unix like systems, this diff patch brings this functionality to Windows systems. This function will return the parent process Id, upon error it raises a WindowsError. This differs from the Unix implementation that never fails. Due to the way Windows returns the parent process Id, a never fail guarantee can not be made. This is a revision of a previous post. The file Issue6394-1.diff contains the updated patches. -- Added file: http://bugs.python.org/file14421/Issue6394-1.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6394 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com