MCPcopy Index your code
hub / github.com/RustPython/RustPython / _spawnvef

Function _spawnvef

Lib/os.py:892–917  ·  view source on GitHub ↗
(mode, file, args, env, func)

Source from the content-addressed store, hash-verified

890 # as execv*()?
891
892 def _spawnvef(mode, file, args, env, func):
893 # Internal helper; func is the exec*() function to use
894 if not isinstance(args, (tuple, list)):
895 raise TypeError('argv must be a tuple or a list')
896 if not args or not args[0]:
897 raise ValueError('argv first element cannot be empty')
898 pid = fork()
899 if not pid:
900 # Child
901 try:
902 if env is None:
903 func(file, args)
904 else:
905 func(file, args, env)
906 except:
907 _exit(127)
908 else:
909 # Parent
910 if mode == P_NOWAIT:
911 return pid # Caller is responsible for waiting!
912 while 1:
913 wpid, sts = waitpid(pid, 0)
914 if WIFSTOPPED(sts):
915 continue
916
917 return waitstatus_to_exitcode(sts)
918
919 def spawnv(mode, file, args):
920 """spawnv(mode, file, args) -> integer

Callers 4

spawnvFunction · 0.85
spawnveFunction · 0.85
spawnvpFunction · 0.85
spawnvpeFunction · 0.85

Calls 6

_exitFunction · 0.90
isinstanceFunction · 0.85
forkFunction · 0.70
funcFunction · 0.50
waitpidFunction · 0.50
waitstatus_to_exitcodeFunction · 0.50

Tested by

no test coverage detected