tag:blogger.com,1999:blog-4704664917418794835.post624213205347835546..comments2023-07-01T05:41:30.469-07:00Comments on Headius: fork and exec on the JVM? JRuby to the Rescue!headiushttp://www.blogger.com/profile/15717357218364947795noreply@blogger.comBlogger16125tag:blogger.com,1999:blog-4704664917418794835.post-39419584963635942102012-06-10T13:26:27.380-07:002012-06-10T13:26:27.380-07:00Is it possible to use spoon to replace something l...Is it possible to use spoon to replace something like the below or would I need to replace the `exec` call?<br /><br />https://gist.github.com/2907212<br /><br />```<br />def run<br /> exec 'some_command'<br />end<br /><br />def run_in_background<br /> pid=fork do<br /> run<br /> end<br />end<br />```Kris Leechhttp://teamcoding.comnoreply@blogger.comtag:blogger.com,1999:blog-4704664917418794835.post-83973791902667031012011-12-22T16:07:44.317-08:002011-12-22T16:07:44.317-08:00I assume that using fork with jruby is discouraged...I assume that using fork with jruby is discouraged?rogerhttp://freeldssheetmusic.orgnoreply@blogger.comtag:blogger.com,1999:blog-4704664917418794835.post-57020087315253270722009-05-14T00:17:00.000-07:002009-05-14T00:17:00.000-07:00Will this be used for system and akin in future ve...Will this be used for system and akin in future versions?Konstantin Haasehttp://twitter.com/konstantinhaasenoreply@blogger.comtag:blogger.com,1999:blog-4704664917418794835.post-56892210720053981032009-05-14T00:40:00.000-07:002009-05-14T00:40:00.000-07:00Konstantin: Maybe. Currently we do a bit of magic ...Konstantin: Maybe. Currently we do a bit of magic to make sure that if you system or exec something like 'ruby blah blah blah' it will just start another JRuby instance in the same process. But it may be desirable for other cases to actually fork+exec so that e.g. terminal applications work correctly.Charles Oliver Nutterhttp://www.blogger.com/profile/06400331959739924670noreply@blogger.comtag:blogger.com,1999:blog-4704664917418794835.post-61106151538436900462009-05-14T06:34:00.000-07:002009-05-14T06:34:00.000-07:00Why make this a separate library? Just integrate i...Why make this a separate library? Just integrate it into Kernel.<br><br>If you can add fork & exec, can you add setsid as well? And if so, well, true background processes for JRuby. :)Daniel Bergerhttp://www.blogger.com/profile/05224445093970941579noreply@blogger.comtag:blogger.com,1999:blog-4704664917418794835.post-8837948825489051242009-05-14T09:42:00.000-07:002009-05-14T09:42:00.000-07:00@overtheline --The point is, with a real fork/exec...@overtheline --<br><br>The point is, with a real fork/exec you don't need to tend the pipes like you would with Runtime.exec.<br><br>-- MarkusQmarkusqhttp://markusq.myopenid.com/noreply@blogger.comtag:blogger.com,1999:blog-4704664917418794835.post-39375015072595032122009-05-14T10:47:00.000-07:002009-05-14T10:47:00.000-07:00@overtheline: How about you have a try getting the...@overtheline: How about you have a try getting the example use case (launch vim in a way that inherits the console STDIN and STDOUT) to work with Runtime.exec and report back on how it goes? I'll be delighted if you can figure out a way to make it work, but I'm pretty sure you won't. <br><br>Runtime.exec is very very limited in what it allows. This is amongst the many examples where it falls down.David R. MacIverhttp://www.blogger.com/profile/17522579015536144620noreply@blogger.comtag:blogger.com,1999:blog-4704664917418794835.post-22303344480686039692009-05-14T10:52:00.000-07:002009-05-14T10:52:00.000-07:00Sun was very serious about "run anywhere"...Sun was very serious about "run anywhere" Most of this discussion is about what was not done on Unix. But since most of this discussion assumes Unix, it's sort of beside the point to harsh java for something it was NOT trying to do, ie expose unix. Java is by it's nature a least common denominator. Love it or leave it. But at least understand it before you complain.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-4704664917418794835.post-1003208044560036372009-05-14T10:59:00.000-07:002009-05-14T10:59:00.000-07:00@Anonymous - I understand it, and it doesn't r...@Anonymous - I understand it, and it doesn't run everywhere. That strategy always ends in failure. They could have recognized this and standardized optional libraries for the most popular server OS in the world... unix.... which sun *also* had a sabre rattling interest in.<br><br>How many of you remember the Java OS? Seriously, not supporting unix/posix APIs just reinforces that old Bill Joy quote ... "there are more smart people outside the company than in it"druhttp://www.blogger.com/profile/15696594951737593474noreply@blogger.comtag:blogger.com,1999:blog-4704664917418794835.post-19171373158481040402009-05-14T11:44:00.000-07:002009-05-14T11:44:00.000-07:00Daniel,To add setsid(), you would do this: attach...Daniel,<br><br>To add setsid(), you would do this:<br><br> attach_function :setsid, [], :int<br><br>in the natural place, then you'll have Exec.setsid.Hirohttp://www.blogger.com/profile/16816839179553173311noreply@blogger.comtag:blogger.com,1999:blog-4704664917418794835.post-48912520929115527332009-05-14T19:32:00.000-07:002009-05-14T19:32:00.000-07:00Awesome job Charles. JRuby really is awesome.Awesome job Charles. JRuby really is awesome.Greghttp://www.blogger.com/profile/16138954675664901193noreply@blogger.comtag:blogger.com,1999:blog-4704664917418794835.post-43392840406301791192009-05-15T01:55:00.000-07:002009-05-15T01:55:00.000-07:00You JRruby guys are superb! The work you've be...You JRruby guys are superb! The work you've been doing makes everyones life lot easier. JRuby has always been such a great project and now this! Thank you!!Nizar Jouininoreply@blogger.comtag:blogger.com,1999:blog-4704664917418794835.post-53046704368208443982009-05-15T15:00:00.000-07:002009-05-15T15:00:00.000-07:00Jan Berkel: We should probably talk about it more,...Jan Berkel: We should probably talk about it more, make sure we've got our ducks in a row. But it works fine for me on OS X, so file a bug or pop on IRC and we'll figure out why it's not working for you.Charles Oliver Nutterhttp://www.blogger.com/profile/06400331959739924670noreply@blogger.comtag:blogger.com,1999:blog-4704664917418794835.post-4761889746895396272009-05-17T05:44:00.000-07:002009-05-17T05:44:00.000-07:00Making subprocessess reliable is hard.E.g. I think...Making subprocessess reliable is hard.<br>E.g. I think you need to close<br>file descriptors in the child<br>before you exec, to avoid some<br>deadlocks.<br><br>I'm surprised that you can execute ruby<br>code after the fork(); I expect that<br>the JVM itself<br>should not be fully functional then.<br>What happens if you gc after fork()?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-4704664917418794835.post-23459325523107660282009-07-31T06:19:18.221-07:002009-07-31T06:19:18.221-07:00Is this going to be solved with the new ProcessBui...Is this going to be solved with the new ProcessBuilder.Redirect addition (Redirect.INHERIT for example) in JDK7?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-4704664917418794835.post-19132249523853230912009-07-31T07:38:13.529-07:002009-07-31T07:38:13.529-07:00Anonymous (immediately above): Very likely...I hav...Anonymous (immediately above): Very likely...I have not had a lot of time to look at NIO2 stuff, but there's a good chance it will solve many of our current issues, including this sort of thing.Charles Oliver Nutterhttp://www.blogger.com/profile/06400331959739924670noreply@blogger.com