Am 07.05.2012 um 20:52 schrieb Sean P. DeNigris:
> How would I run '/usr/bin/java -jar "/path/to/jenkins.war" &' with OSProcess?
> Specifically I want to know the process number of the java child process.
>
> I unsuccessfully tried:
> * PipeableOSProcess command: '/usr/bin/java -jar "/path/to/jenkins.war" &',
> which successfully launches java, but I don't know its pid because the
> returned process is the completed parent "sh" that launched it
> * PipeableOSProcess command: '/usr/bin/java -jar "/path/to/jenkins.war"'
> (without ampersand), which also launches successfully, and leaves the parent
> "sh" process running as well (not as clean), but I still don't know the java
> pid
>
If this is all shell handling then you should be able to exec your command. An
exec /usr/bin/java -jar "/path/to/jenkins.war"
(if it works) will replace the shell with the execution of the java process.
Therefor the pid is the pid of the java process. But Yannis approach looks a
lot better from here :)
Norbert
> I then succeeded with:
> p := PipeableOSProcess command: '/usr/bin/java -jar "/path/to/jenkins.war"
> & { echo $! ; }'.
> p output lines first.
>
> But this seems convoluted and I'm assuming there must be a simpler way.
>
> What is the best way to do this?
> I.e.:
> * launch a long running child process
> * without keeping the sh process open
> * accessing the pid of the child
>
> Thanks,
> Sean
>
> --
> View this message in context:
> http://forum.world.st/Running-in-background-with-OSProcess-tp4615534.html
> Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
>