{"action":"created","issue":{"url":"https://api.github.com/repos/jruby/jruby/issues/3352","labels_url":"https://api.github.com/repos/jruby/jruby/issues/3352/labels{/name}","comments_url":"https://api.github.com/repos/jruby/jruby/issues/3352/comments","events_url":"https://api.github.com/repos/jruby/jruby/issues/3352/events","html_url":"https://github.com/jruby/jruby/issues/3352","id":108385125,"number":3352,"title":"/tmp/jrubyXXX.jar files are left in place by classloader if process is SIGKILLed","user":{"login":"rtyler","id":26594,"avatar_url":"https://avatars.githubusercontent.com/u/26594?v=3","gravatar_id":"","url":"https://api.github.com/users/rtyler","html_url":"https://github.com/rtyler","followers_url":"https://api.github.com/users/rtyler/followers","following_url":"https://api.github.com/users/rtyler/following{/other_user}","gists_url":"https://api.github.com/users/rtyler/gists{/gist_id}","starred_url":"https://api.github.com/users/rtyler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rtyler/subscriptions","organizations_url":"https://api.github.com/users/rtyler/orgs","repos_url":"https://api.github.com/users/rtyler/repos","events_url":"https://api.github.com/users/rtyler/events{/privacy}","received_events_url":"https://api.github.com/users/rtyler/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/jruby/jruby/labels/java%20integration","name":"java integration","color":"000000"},{"url":"https://api.github.com/repos/jruby/jruby/labels/JRuby%201.7.x","name":"JRuby 1.7.x","color":"eb6420"},{"url":"https://api.github.com/repos/jruby/jruby/labels/JRuby%209000","name":"JRuby 9000","color":"bfe5bf"}],"state":"open","locked":false,"assignee":{"login":"mkristian","id":35058,"avatar_url":"https://avatars.githubusercontent.com/u/35058?v=3","gravatar_id":"","url":"https://api.github.com/users/mkristian","html_url":"https://github.com/mkristian","followers_url":"https://api.github.com/users/mkristian/followers","following_url":"https://api.github.com/users/mkristian/following{/other_user}","gists_url":"https://api.github.com/users/mkristian/gists{/gist_id}","starred_url":"https://api.github.com/users/mkristian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mkristian/subscriptions","organizations_url":"https://api.github.com/users/mkristian/orgs","repos_url":"https://api.github.com/users/mkristian/repos","events_url":"https://api.github.com/users/mkristian/events{/privacy}","received_events_url":"https://api.github.com/users/mkristian/received_events","type":"User","site_admin":false},"milestone":null,"comments":1,"created_at":"2015-09-25T18:41:02Z","updated_at":"2015-09-25T18:48:50Z","closed_at":null,"body":"When JRuby is executing via jruby-complete or another embedded type use-case, and it loads jars of some form or another a number of `/tmp/jruby*.jar` files are created.\r\n\r\nUnder \"normal\" conditions these files stick around and are removed by something when the process is sent SIGTERM or SIGINT.\r\n\r\nA SIGKILL however will result in the files littering the `/tmp` directory indefinitely.\r\n\r\n## Reproduction Steps\r\n\r\n* `java -cp ./jruby-complete-9.0.1.0.jar org.jruby.Main -e \"puts 'hello'; require 'openssl'; puts 'loaded'; sleep 60\"`\r\n* `ls /tmp | grep -i jar`\r\n```\r\n➜  ~  ls /tmp | grep -i jar\r\njruby2147863957306982519jopenssl.jar\r\njruby3032390121297627542bcpkix-jdk15on-1.50.jar\r\njruby6589611494165220974bcprov-jdk15on-1.50.jar\r\n➜  ~  \r\n```\r\n* kill process with SIGKILL\r\n\r\n## Suggested solutions\r\n\r\nIt's not clear to me whether these files are needed after the classes are loaded into the runtime or not. If they are not needed, we could employ a similar fix to #1237 which was fixed with jnr/jffi#13\r\n\r\nIf they are needed for the duration of the runtime, then it would at least be useful to write the files with the PID of the Java process or something similar so a user can safely remove ones that are stale or no longer needed\r\n"},"comment":{"url":"https://api.github.com/repos/jruby/jruby/issues/comments/143319621","html_url":"https://github.com/jruby/jruby/issues/3352#issuecomment-143319621","issue_url":"https://api.github.com/repos/jruby/jruby/issues/3352","id":143319621,"user":{"login":"rtyler","id":26594,"avatar_url":"https://avatars.githubusercontent.com/u/26594?v=3","gravatar_id":"","url":"https://api.github.com/users/rtyler","html_url":"https://github.com/rtyler","followers_url":"https://api.github.com/users/rtyler/followers","following_url":"https://api.github.com/users/rtyler/following{/other_user}","gists_url":"https://api.github.com/users/rtyler/gists{/gist_id}","starred_url":"https://api.github.com/users/rtyler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rtyler/subscriptions","organizations_url":"https://api.github.com/users/rtyler/orgs","repos_url":"https://api.github.com/users/rtyler/repos","events_url":"https://api.github.com/users/rtyler/events{/privacy}","received_events_url":"https://api.github.com/users/rtyler/received_events","type":"User","site_admin":false},"created_at":"2015-09-25T18:48:50Z","updated_at":"2015-09-25T18:48:50Z","body":"Thinking a bit outside the box here, we could use ShrinkWrap and their [ShrinkWrapClassLoader](http://docs.jboss.org/shrinkwrap/1.0.0-alpha-12/org/jboss/shrinkwrap/api/classloader/ShrinkWrapClassLoader.html) which would obviate the need for [JRubyClassLoader](https://github.com/jruby/jruby/blob/master/core/src/main/java/org/jruby/util/JRubyClassLoader.java#L64-L65) to copy files to /tmp"}}