java - Graceful kill of Apache Commons Exec process -
i starting external process in java program (on linux) , need ability send sigterm signal rather sigkill exec.getwatchdog().destroyprocess()
sending. there way can more gracefully stop unix process started commons-exec? or can pid can run appropriate kill command myself?
well, commons exec relies on java process class, doesn't expose pid. it's used kill process, it's not can change behavior of. nice , encapsulated. gotta love oo, eh?
if launching processes in background, can wrap them in simple shell script captures pid you, , saves off "known place" java routine knows about. still kind of messy, and, naturally, doesn't port other platforms well.
you can write own exec function using jni capture information well, that's less friendly.
you write platform specific exec launcher daemon in more system oriented (c, python, etc.). send messages launch , stop things, , handles process you. 1 benefit of don't have fork jvm when run new process (which can quite expensive depending on jvm size).
you can start daemon @ beginning , share socket or pipe (both pretty portable). that's not horribly inelegant solution, , compartmentalizes lot of system specific behavior (so can have different process on, say, windows vs unix , java stays same, need port little daemon), without having run jni.
Comments
Post a Comment