Skip to content

Commit 3b0b506

Browse files
Initialization of dpctl to set subprocess to not use FORK on Linux
Fork is not supported by DPC++ runtime. Attempt to use fork may cause hangs, or incorrect behavior. In particular, it may affect working on oneapi-gdb. To enable smooth experience in debugging kernels launched by dpctl, or extensions built using dpctl C++ API, initialization of dpctl on Linux, imports subprocess and sets its configuration variables to use SPAWN over FORK https://docs.python.org/3/library/subprocess.html#disabling-use-of-vfork-or-posix-spawn
1 parent b51a19f commit 3b0b506

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

dpctl/_init_helper.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,20 @@
3232
os.add_dll_directory(dll_dir)
3333

3434
del is_venv_win32
35+
36+
is_linux = sys.platform.startswith("linux")
37+
38+
if is_linux:
39+
# forking is not supported by device drivers
40+
# Configure subprocess (used by versioneer) to
41+
# use SPAWN method over FORK method to enable
42+
# use of gdb-oneapi to debug code launched by
43+
# native extensions that used dpctl C/C++ API
44+
import subprocess
45+
46+
subprocess._USE_VFORK = False
47+
subprocess._USE_POSIX_SPAWN = True
48+
# remove qualifier from this namespace
49+
del subprocess
50+
51+
del is_linux

0 commit comments

Comments
 (0)