Skip to content

Commit 7437266

Browse files
committed
pytest-server-fixtures: Support large pids in xvfb
Since a large number of 64 bit distributions are now using larger PIDs than 65535 by default, and the xvfb fixtures makes the assumption that PIDs are going to be less than that, check what the maximum is, falling back to 65535 if we can't.
1 parent 286e040 commit 7437266

File tree

1 file changed

+4
-1
lines changed
  • pytest-server-fixtures/pytest_server_fixtures

1 file changed

+4
-1
lines changed

pytest-server-fixtures/pytest_server_fixtures/xvfb.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ class XvfbServer(object):
4343

4444
def __init__(self):
4545
tmpdir = mkdtemp(prefix='XvfbServer.', dir=Workspace.get_base_tempdir())
46-
for servernum in range(os.getpid(), 65536):
46+
pid_max = 65536
47+
with open('/proc/sys/kernel/pid_max') as pid_max_file:
48+
pid_max = int(pid_max_file.read())
49+
for servernum in range(os.getpid(), pid_max):
4750
if os.path.exists('/tmp/.X{0}-lock'.format(servernum)):
4851
continue
4952
self.display = ':' + str(servernum)

0 commit comments

Comments
 (0)