> Mark Hammond replied: > > This worked for me just then: > > >>> os.spawnl(os.P_NOWAIT, "f:\\windows\\notepad.exe") > 548 > >>> import win32api > >>> win32api.TerminateProcess(548,0) > > Tim also replied: > > Tim> For 2.3, I implemented something or other for the Python core; > Tim> probably killpid(); > > Shouldn't one of these solutions (or some variant) appear under the veneer > of os.kill()? I realize the semantics might not be exactly the same The key difference is that kill() wants a PID, while TerminateProcess wants a handle. Now, we *could* add a kill() (assuming it is not already there) but that would not solve your specific problem, as you have a handle and you would then need a platform specific way to convert it to a PID. It seems too hard to win. > (perhaps Windows solutions don't support different signals or a different > set of signals), but it seems to me that if an attempt is made to provide > the os.spawn* functions across platforms we should make a similar > attempt to > provide a way to kill spawned processes as well. Yes, a higher-level execution API would be worthwhile, especially if that could be expressed using posix semantics as a fallback. I am thinking of what threading is to thread, this new API could be to the various spawn/exec/popen functions. > Corollary question: Is there some reason the win32api stuff isn't in the > core? Even if we ignore Tim's requirements ('cos I know I will <wink>) there is still alot of work, and a *huge* amount of code. Do we want win32api, all of the "win32*" modules in win32all, or all of win32all. The win32api modules seems very useful, and it is for trivial things - but once you start doing real things, the other win32 modules start becoming useful, and so it goes. On the other hand, if these extensions were in the core, I wouldn't personally be worrying about those damn hex literal warnings <wink>. Mark.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4