Skip to content

Commit 6f90560

Browse files
authored
Merge pull request #4733 from grandixximo/gui-spawn-no-fork
Fix GUI startup ENOMEM on small-RAM machines with an OpenMP OpenBLAS
2 parents 5a3d2f7 + d53b4d9 commit 6f90560

5 files changed

Lines changed: 18 additions & 13 deletions

File tree

‎scripts/linuxcnc.in‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ if [[ ! -v LINUXCNC_OPENGL_PLATFORM || "${LINUXCNC_OPENGL_PLATFORM}" == "glx" ]]
3333
export QT_QPA_PLATFORM="xcb"
3434
fi
3535

36+
# An OpenMP build of OpenBLAS reserves about 1 GiB per CPU when numpy
37+
# is imported; with less RAM than that the kernel refuses to fork the
38+
# GUI (ENOMEM). Nothing here needs threaded BLAS.
39+
export OMP_NUM_THREADS="${OMP_NUM_THREADS:-1}"
40+
3641
################################################################################
3742
# 0. Values that come from configure
3843
################################################################################

‎src/emc/usr_intf/axis/scripts/axis.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020

2121
# import pdb
22-
import sys, os
22+
import sys, os, subprocess
2323
import string
2424
BASE = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), ".."))
2525
sys.path.insert(0, os.path.join(BASE, "lib", "python"))
@@ -4298,15 +4298,15 @@ def check_dynamic_tabs():
42984298
if postgui_halfile is not None:
42994299
for f in postgui_halfile:
43004300
if f.lower().endswith('.tcl'):
4301-
res = os.spawnvp(os.P_WAIT, "haltcl", ["haltcl", "-i", vars.emcini.get(), f])
4301+
res = subprocess.call(["haltcl", "-i", vars.emcini.get(), f])
43024302
else:
4303-
res = os.spawnvp(os.P_WAIT, "halcmd", ["halcmd", "-i", vars.emcini.get(), "-f", f])
4303+
res = subprocess.call(["halcmd", "-i", vars.emcini.get(), "-f", f])
43044304
if res: raise SystemExit(res)
43054305

43064306
if postgui_halcmds is not None:
43074307
for f in postgui_halcmds:
43084308
f = os.path.expanduser(f)
4309-
res = os.spawnvp(os.P_WAIT, "halcmd", ["halcmd"] + f.split())
4309+
res = subprocess.call(["halcmd"] + f.split())
43104310
if res: raise SystemExit(res)
43114311

43124312
open_initial_file()

‎src/emc/usr_intf/gmoccapy/gmoccapy.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6678,9 +6678,9 @@ def _make_hal_pins(self):
66786678
if postgui_halfile is not None:
66796679
for f in postgui_halfile:
66806680
if f.lower().endswith('.tcl'):
6681-
res = os.spawnvp(os.P_WAIT, "haltcl", ["haltcl", "-i", inifile, f])
6681+
res = subprocess.call(["haltcl", "-i", inifile, f])
66826682
else:
6683-
res = os.spawnvp(os.P_WAIT, "halcmd", ["halcmd", "-i", inifile, "-f", f])
6683+
res = subprocess.call(["halcmd", "-i", inifile, "-f", f])
66846684
if res:
66856685
LOG.error('postgui halfile error:{}'.format(res))
66866686
raise SystemExit(res)
@@ -6690,7 +6690,7 @@ def _make_hal_pins(self):
66906690
if postgui_halcmds is not None:
66916691
for f in postgui_halcmds:
66926692
f = os.path.expanduser(f)
6693-
res = os.spawnvp(os.P_WAIT, "halcmd", ["halcmd"] + f.split())
6693+
res = subprocess.call(["halcmd"] + f.split())
66946694
if res:
66956695
LOG.error('postgui command error:{}'.format(res))
66966696
raise SystemExit(res)
@@ -6718,7 +6718,7 @@ def _terminate(signum, frame):
67186718
signal.signal(signal.SIGINT, _terminate)
67196719

67206720
# The startup handler's SystemExit is lost where Python ignores
6721-
# exceptions, as in the os.fork() hooks of the postgui spawns above.
6721+
# exceptions, such as in an os.fork() hook.
67226722
# The flag still says that a SIGTERM came.
67236723
if _terminate_requested:
67246724
LOG.info("gmoccapy received SIGTERM during startup, shutting down")

‎src/emc/usr_intf/gscreen/gscreen.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4797,9 +4797,9 @@ def __setitem__(self, item, value):
47974797
if postgui_halfile is not None:
47984798
for f in postgui_halfile:
47994799
if f.lower().endswith('.tcl'):
4800-
res = os.spawnvp(os.P_WAIT, "haltcl", ["haltcl", "-i", inifile, f])
4800+
res = subprocess.call(["haltcl", "-i", inifile, f])
48014801
else:
4802-
res = os.spawnvp(os.P_WAIT, "halcmd", ["halcmd", "-i", inifile, "-f", f])
4802+
res = subprocess.call(["halcmd", "-i", inifile, "-f", f])
48034803
if res: raise SystemExit(res)
48044804
Gtk.main()
48054805

‎src/emc/usr_intf/qtvcp/qtvcp.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -499,9 +499,9 @@ def postgui(self):
499499
for f in postgui_halfile:
500500
f = os.path.expanduser(f)
501501
if f.lower().endswith('.tcl'):
502-
res = os.spawnvp(os.P_WAIT, "haltcl", ["haltcl", "-i",self.inipath, f])
502+
res = subprocess.call(["haltcl", "-i",self.inipath, f])
503503
else:
504-
res = os.spawnvp(os.P_WAIT, "halcmd", ["halcmd", "-i",self.inipath,"-f", f])
504+
res = subprocess.call(["halcmd", "-i",self.inipath,"-f", f])
505505
if res: raise SystemExit(res)
506506

507507
def postgui_cmd(self):
@@ -510,7 +510,7 @@ def postgui_cmd(self):
510510
if postgui_commands is not None:
511511
for f in postgui_commands:
512512
f = os.path.expanduser(f)
513-
res = os.spawnvp(os.P_WAIT, "halcmd", ["halcmd"] + f.split())
513+
res = subprocess.call(["halcmd"] + f.split())
514514
if res: raise SystemExit(res)
515515

516516
# This can be called by control c or an early error.

0 commit comments

Comments
 (0)