Skip to content

Commit 5d9716c

Browse files
committed
[Truffle] Add Process.ppid
1 parent 9d0feae commit 5d9716c

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

truffle/src/main/java/org/jruby/truffle/nodes/rubinius/PosixNodes.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,20 @@ public int isATTY(int fd) {
615615

616616
}
617617

618+
@CoreMethod(names = "getppid", isModuleFunction = true)
619+
public abstract static class GetppidNode extends CoreMethodArrayArgumentsNode {
620+
621+
public GetppidNode(RubyContext context, SourceSection sourceSection) {
622+
super(context, sourceSection);
623+
}
624+
625+
@Specialization
626+
public int getppid() {
627+
return posix().getppid();
628+
}
629+
630+
}
631+
618632
@CoreMethod(names = "symlink", isModuleFunction = true, required = 2)
619633
public abstract static class SymlinkNode extends CoreMethodArrayArgumentsNode {
620634

truffle/src/main/ruby/core/rubinius/common/process.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,12 @@ def self.getpgrp
9090
ret
9191
end
9292

93+
def self.ppid
94+
ret = FFI::Platform::POSIX.getppid
95+
Errno.handle if ret == -1
96+
ret
97+
end
98+
9399
def self.uid=(uid)
94100
# the 4 rescue clauses below are needed
95101
# until respond_to? can be used to query the implementation of methods attached via FFI

0 commit comments

Comments
 (0)