File tree Expand file tree Collapse file tree 5 files changed +75
-85
lines changed
dev/com.ibm.ws.kernel.boot.core/src/com/ibm/ws/kernel/boot/internal Expand file tree Collapse file tree 5 files changed +75
-85
lines changed Original file line number Diff line number Diff line change @@ -29,20 +29,20 @@ public FileShareLockProcessStatusImpl(File file) {
2929 }
3030
3131 @ Override
32- public boolean isPossiblyRunning () {
32+ public ProcessStatus . State isPossiblyRunning () {
3333 if (file .exists ()) {
3434 try {
3535 new FileOutputStream (file , true ).close ();
3636 } catch (FileNotFoundException e ) {
3737 // "java.io.FileNotFoundException: C:\...\logs\console.log
3838 // (The process cannot access the file because it is being used
3939 // by another process.)"
40- return true ;
40+ return State . YES ;
4141 } catch (IOException e ) {
4242 Debug .printStackTrace (e );
4343 }
4444 }
4545
46- return false ;
46+ return State . NO ;
4747 }
4848}
Original file line number Diff line number Diff line change @@ -29,19 +29,19 @@ public class PSProcessStatusImpl implements ProcessStatus {
2929
3030 /**
3131 * @param pid the pid, or the empty string if {@link #isPossiblyRunning} should
32- * always return true
32+ * always return true
3333 */
3434 public PSProcessStatusImpl (String pid ) {
3535 this .pid = pid ;
3636 }
3737
3838 @ Override
39- public boolean isPossiblyRunning () {
39+ public State isPossiblyRunning () {
4040 if (pid .isEmpty ()) {
4141 // OS/400 shell does not support $!, so an empty PID is always
4242 // passed (unless native integration is enabled). Return true since
4343 // the process might be running.
44- return true ;
44+ return State . YES ;
4545 }
4646
4747 ProcessBuilder pb = new ProcessBuilder ();
@@ -68,8 +68,14 @@ public boolean isPossiblyRunning() {
6868 }
6969
7070 p .waitFor ();
71- return p .exitValue () == 0 ;
71+ if (p .exitValue () == 0 )
72+ return State .YES ;
73+ else
74+ return State .NO ;
7275 } catch (IOException e ) {
76+ if (e .getMessage ().equals ("No such file or directory" )) // "ps" doesn't exist on this machine.
77+ // Return Undetermined since we can't poll the process
78+ return State .UNDETERMINED ;
7379 Debug .printStackTrace (e );
7480 } catch (InterruptedException e ) {
7581 Debug .printStackTrace (e );
@@ -78,6 +84,6 @@ public boolean isPossiblyRunning() {
7884 Utils .tryToClose (reader );
7985 }
8086
81- return true ;
87+ return State . YES ;
8288 }
8389}
Original file line number Diff line number Diff line change 1414 * Monitors the status of a running process.
1515 */
1616public interface ProcessStatus {
17+ public enum State {
18+ YES , NO , UNDETERMINED
19+ }
20+
1721 /**
1822 * Returns true if the process is possibly running.
1923 */
20- boolean isPossiblyRunning ();
24+ State isPossiblyRunning ();
2125}
You can’t perform that action at this time.
0 commit comments