Os.kill does not raise an OSError, however I do not see this pid work

On my ubuntu server, I run the following command:

python -c 'import os; os.kill(5555, 0)'

This is done so that I can see if pid 5555 is working. In my opinion, this should raise an OSError if pid is not working. This does not raise an OSError for me, which means that this must be a running process. However, when I run:

ps aux | grep 5555

I see that the process is not working with this pid. This also occurs at several other peaks in this general range, but this does not occur, for example, 555 or 55555.

Does anyone have an idea why os.kill will not raise an OSError as expected?

Note: this runs under python 2.5.1.

+3
source share
4

linux pid. os.kill , pid pid , ps pids.

, PID 8502 ,

$ ls /proc/8502/task/
8502  8503  8504  8505  8506  8507  8511  8512  8514  8659

, 8503

$ ps aux | grep [8]503
$

, ps,

$ ps -eLf | grep [8]503
ncw       8502     1  8503  0   10 10:00 ?        00:00:00 /usr/lib/virtualbox/VBoxSVC --automate

(Grepping [8]503 , grep - unix!)

,

$ python
Python 2.6.4 (r264:75706, Nov  2 2009, 14:44:17)
[GCC 4.4.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Loaded customisations from '/home/ncw/.pystartup'
>>> import os
>>> os.kill(8503, 0)
>>>

.

,

ls /proc/*/task/5555

ps -eLf | grep [5]555

.

+6

htop (sudo apt-get install htop), , ps.

+1

, 2.5? 2.6.4 :

gruszczy@gruszczy-laptop:~$ python -c 'import os; os.kill(5555, 0)'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
OSError: [Errno 3] No such process

, :

http://mail.python.org/pipermail/new-bugs-announce/2009-February/004222.html

+1
source

I do not know why this OSError does not occur in some cases, but it is important to note that on Linux and Unix OS there is a maximum pid value:

$> cat /proc/sys/kernel/pid_max
32768
0
source

Source: https://habr.com/ru/post/1724395/


All Articles