[Tutor] Python working with Bash....arrrggggh!

Steven D'Aprano steve at pearwood.info
Fri Aug 24 11:24:31 CEST 2012


On 24/08/12 17:05, Ray Jones wrote:
>
> On 08/24/2012 12:02 AM, Steven D'Aprano wrote:
>> On 24/08/12 16:27, Ray Jones wrote:
>>
>>> I am forever confused, however, on which methods can be found where. I
>>> just spent quarter of an hour searching in sys,* os.*, and shutil.*. for
>>> a 'kill' command that I knew I'd seen before....I found it hidden in
>>> subprocess.Popen. Arrrgggh. These various imports are going to drive me
>>> to drink!
>>
>> Possibly you've already started the drive? *wink*
>>
>> There is an os.kill.
>>
>>
>> http://docs.python.org/library/os.html#os.kill
>
> Yes, I'd found that, but that requires a file descriptor rather than a
> file object - and I haven't advanced to file descriptors yet.... ;)


os.kill doesn't take a file descriptor. It's a wrapper around the Unix/Linux kill command, and so takes a process id and a signal, exactly as you would use if you were using kill in the shell.

As the Fine Manual says:

     os.kill(pid, sig)

     Send signal sig to the process pid. Constants for the specific signals
     available on the host platform are defined in the signal module.




-- 
Steven


More information about the Tutor mailing list