Skip to content

Commit 1cb13da

Browse files
committed
provide some _posix functions for process control
1 parent 7d7ccda commit 1cb13da

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/PosixModuleBuiltins.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@ public class PosixModuleBuiltins extends PythonBuiltins {
126126
private static final int SEEK_CUR = 1;
127127
private static final int SEEK_END = 2;
128128

129+
private static final int WNOHANG = 1;
130+
private static final int WUNTRACED = 3;
131+
129132
private static final int F_OK = 0;
130133
private static final int X_OK = 1;
131134

@@ -248,6 +251,9 @@ public PosixModuleBuiltins() {
248251
builtinConstants.put("SEEK_CUR", SEEK_CUR);
249252
builtinConstants.put("SEEK_END", SEEK_END);
250253

254+
builtinConstants.put("WNOHANG", WNOHANG);
255+
builtinConstants.put("WUNTRACED", WUNTRACED);
256+
251257
builtinConstants.put("F_OK", F_OK);
252258
builtinConstants.put("X_OK", X_OK);
253259
}
@@ -1018,6 +1024,16 @@ private int getLength(PTuple times) {
10181024
}
10191025
}
10201026

1027+
@Builtin(name = "waitpid", fixedNumOfPositionalArgs = 2)
1028+
@GenerateNodeFactory
1029+
abstract static class WaitpidNode extends PythonBinaryBuiltinNode {
1030+
@SuppressWarnings("unused")
1031+
@Specialization
1032+
PTuple waitpid(int pid, int options) {
1033+
throw raise(NotImplementedError, "waitpid");
1034+
}
1035+
}
1036+
10211037
// FIXME: this is not nearly ready, just good enough for now
10221038
@Builtin(name = "system", fixedNumOfPositionalArgs = 1)
10231039
@GenerateNodeFactory

graalpython/lib-graalpython/posix.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,33 @@ def __next__(self):
9797
@__builtin__
9898
def scandir(path):
9999
return ScandirIterator(iter(listdir(path)))
100+
101+
102+
@__builtin__
103+
def WIFSIGNALED(status):
104+
return status > 128
105+
106+
107+
@__builtin__
108+
def WIFEXITED(status):
109+
return not WIFSIGNALED(status)
110+
111+
112+
@__builtin__
113+
def WTERMSIG(status):
114+
return status - 128
115+
116+
117+
@__builtin__
118+
def WEXITSTATUS(status):
119+
return status & 127
120+
121+
122+
@__builtin__
123+
def WIFSTOPPED(status):
124+
return False
125+
126+
127+
@__builtin__
128+
def WSTOPSIG(status):
129+
return 0

0 commit comments

Comments
 (0)