Skip to content

Commit

Permalink
[Truffle] Call Process.setproctitle when writing to $0.
Browse files Browse the repository at this point in the history
  • Loading branch information
eregon committed Dec 2, 2016
1 parent 313ab77 commit 430a591
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
1 change: 0 additions & 1 deletion spec/truffle/tags/language/predefined_tags.txt
Expand Up @@ -3,6 +3,5 @@ slow:The predefined global constant STDIN retains the encoding set by #set_encod
slow:The predefined global constant STDIN has the encodings set by #set_encoding
slow:The predefined global constant STDOUT has the encodings set by #set_encoding
slow:The predefined global constant ARGV contains Strings encoded in locale Encoding
linux:Global variable $0 actually sets the program name
slow:Global variable $0 is the path given as the main script and the same as __FILE__
slow:Global variable $? is thread-local
4 changes: 4 additions & 0 deletions truffle/src/main/java/org/jruby/truffle/core/CoreLibrary.java
Expand Up @@ -1357,6 +1357,10 @@ public DynamicObject getProcClass() {
return procClass;
}

public DynamicObject getProcessModule() {
return processModule;
}

public DynamicObject getRangeClass() {
return rangeClass;
}
Expand Down
Expand Up @@ -1765,8 +1765,10 @@ public RubyNode visitGlobalAsgnNode(GlobalAsgnParseNode node) {
final RubyNode translated;

if (name.equals("$0")) {
translated = VMPrimitiveNodesFactory.VMSetProcessTitleNodeFactory.create(
new RubyNode[]{ writeGlobalVariableNode });
// Call Process.setproctitle
RubyNode processClass = new ObjectLiteralNode(context, fullSourceSection, context.getCoreLibrary().getProcessModule());
translated = new RubyCallNode(new RubyCallNodeParameters(context, fullSourceSection, processClass, "setproctitle", null,
new RubyNode[]{writeGlobalVariableNode}, false, false));
} else {
translated = writeGlobalVariableNode;
}
Expand Down

0 comments on commit 430a591

Please sign in to comment.