Skip to content

Commit

Permalink
Showing 8 changed files with 82 additions and 7 deletions.
3 changes: 2 additions & 1 deletion truffle/pom.rb
Original file line number Diff line number Diff line change
@@ -28,7 +28,8 @@
:id => 'anno',
:phase => 'process-resources',
'includes' => [ 'org/jruby/truffle/om/dsl/processor/OMProcessor.java' ],
'compilerArgs' => [ '-J-ea' ] )
'compilerArgs' => [ '-XDignore.symbol.file=true',
'-J-ea' ] )
execute_goals( 'compile',
:id => 'default-compile',
:phase => 'compile',
1 change: 1 addition & 0 deletions truffle/pom.xml
Original file line number Diff line number Diff line change
@@ -65,6 +65,7 @@ DO NOT MODIFIY - GENERATED CODE
<include>org/jruby/truffle/om/dsl/processor/OMProcessor.java</include>
</includes>
<compilerArgs>
<compilerArg>-XDignore.symbol.file=true</compilerArg>
<compilerArg>-J-ea</compilerArg>
</compilerArgs>
</configuration>
Original file line number Diff line number Diff line change
@@ -22,8 +22,8 @@
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.control.RaiseException;
import org.jruby.truffle.runtime.layouts.Layouts;
import org.jruby.truffle.runtime.signal.Signal;
import org.jruby.truffle.runtime.signal.SignalOperations;
import sun.misc.Signal;

@SuppressWarnings("restriction")
@CoreClass(name = "Process")
Original file line number Diff line number Diff line change
@@ -65,11 +65,11 @@
import org.jruby.truffle.runtime.control.ThrowException;
import org.jruby.truffle.runtime.layouts.Layouts;
import org.jruby.truffle.runtime.signal.ProcSignalHandler;
import org.jruby.truffle.runtime.signal.Signal;
import org.jruby.truffle.runtime.signal.SignalOperations;
import org.jruby.truffle.runtime.subsystems.ThreadManager;
import org.jruby.util.StringSupport;
import org.jruby.util.io.PosixShim;
import sun.misc.Signal;

import java.lang.management.ManagementFactory;
import java.lang.management.ThreadMXBean;
Original file line number Diff line number Diff line change
@@ -16,8 +16,6 @@
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.layouts.Layouts;
import org.jruby.truffle.runtime.subsystems.SafepointAction;
import sun.misc.Signal;
import sun.misc.SignalHandler;

@SuppressWarnings("restriction")
public class ProcSignalHandler implements SignalHandler {
61 changes: 61 additions & 0 deletions truffle/src/main/java/org/jruby/truffle/runtime/signal/Signal.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved. This
* code is released under a tri EPL/GPL/LGPL license. You can use it,
* redistribute it and/or modify it under the terms of the:
*
* Eclipse Public License version 1.0
* GNU General Public License version 2
* GNU Lesser General Public License version 2.1
*/
package org.jruby.truffle.runtime.signal;

import java.util.Map;
import java.util.WeakHashMap;

public class Signal {

private final sun.misc.Signal signal;

private final static Map<sun.misc.SignalHandler, SignalHandler> handlers = new WeakHashMap<>();

public Signal(String name) {
signal = new sun.misc.Signal(name);
}

public static SignalHandler handle(final Signal signal, final SignalHandler newHandler) {
final sun.misc.SignalHandler wrappedNewHandler = new sun.misc.SignalHandler() {

@Override
public void handle(sun.misc.Signal wrappedSignal) {
newHandler.handle(signal);
}

};

synchronized (handlers) {
handlers.put(wrappedNewHandler, newHandler);

final sun.misc.SignalHandler oldWrappedHandler = sun.misc.Signal.handle(signal.signal, wrappedNewHandler);

SignalHandler oldHandler = handlers.getOrDefault(oldWrappedHandler, null);

if (oldHandler == null) {
oldHandler = new SignalHandler() {
@Override
public void handle(Signal signal) {
oldWrappedHandler.handle(signal.signal);
}
};

handlers.put(oldWrappedHandler, oldHandler);
}

return oldHandler;
}
}

public static void raise(Signal signal) {
sun.misc.Signal.raise(signal.signal);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved. This
* code is released under a tri EPL/GPL/LGPL license. You can use it,
* redistribute it and/or modify it under the terms of the:
*
* Eclipse Public License version 1.0
* GNU General Public License version 2
* GNU Lesser General Public License version 2.1
*/
package org.jruby.truffle.runtime.signal;

public interface SignalHandler {

void handle(Signal signal);

}
Original file line number Diff line number Diff line change
@@ -10,8 +10,6 @@
package org.jruby.truffle.runtime.signal;

import org.jruby.RubySignal;
import sun.misc.Signal;
import sun.misc.SignalHandler;

import java.util.Collections;
import java.util.Map;

0 comments on commit 876f2e5

Please sign in to comment.