Skip to content

Commit ffb88af

Browse files
committed
Make fd non-iheritable in FileIO
1 parent 4dea0e2 commit ffb88af

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/FileIOBuiltins.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,12 @@ public PNone doInit(VirtualFrame frame, PFileIO self, Object nameobj, String mod
356356
throw raise(ValueError, OPENER_RETURNED_D, self.getFD());
357357
}
358358
}
359+
try {
360+
posixLib.setInheritable(getPosixSupport(), self.getFD(), false);
361+
} catch (PosixSupportLibrary.PosixException e) {
362+
exceptionProfile.enter();
363+
throw raiseOSErrorFromPosixException(frame, e);
364+
}
359365
fdIsOwn = true;
360366
}
361367
self.setBlksize(DEFAULT_BUFFER_SIZE);

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/ImageBuildtimePosixSupport.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,10 @@ final boolean getInheritable(int fd,
220220
@ExportMessage
221221
final void setInheritable(int fd, boolean inheritable,
222222
@CachedLibrary("this.nativePosixSupport") PosixSupportLibrary nativeLib) throws PosixException {
223-
checkNotInImageBuildtime();
223+
if (ImageInfo.inImageBuildtimeCode()) {
224+
PosixSupportLibrary.getUncached().setInheritable(emulatedPosixSupport, fd, inheritable);
225+
return;
226+
}
224227
nativeLib.setInheritable(nativePosixSupport, fd, inheritable);
225228
}
226229

0 commit comments

Comments
 (0)