File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes stop parent process Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "stop parent process" Watch "stop parent process" New topic

stop parent process

Lee Xu
Ranch Hand

Joined: Aug 24, 2001
Posts: 77
Is it possible to stop parent process before the end of child process? How? I got this question during interview.
James Gray
Ranch Hand

Joined: Sep 10, 2001
Posts: 30
I should probably preface this answer with that fact that I have never launched a single process from a Java application before.
However, a quick trip over to the API and I'm pretty sure I can safely say yes. The Process object, returned by Runtime.exec(), has a destory() method that appearently forcably terminates the process.
That's a pretty ugly interview question, in my opinion. Is it common to be such a specific question in Java position interviews?
Michael Ernest
High Plains Drifter

Joined: Oct 25, 2000
Posts: 7292

Is this even a Java question? is what I'm curious about, since process creation and handling is not a platform-independent discussion.
When a parent dies, it may HUP dependent child processes; you may see this behavior when you close the window that launched your browser, taking the browser with it.
nohup(1), when used to load a command, allows the resulting process to ignore the death of its parent and continue processing.
Michael Ernest, co-author of: The Complete Java 2 Certification Study Guide

Make visible what, without you, might perhaps never have been seen.
- Robert Bresson
Sagar Bilgi
Ranch Hand

Joined: Apr 26, 2001
Posts: 37
I believe it was more of an OS question. I know at least in Unix, if a parent process dies before the child completes execution the child becomes an orphan process and is adopted by the init process.( I think it has a PID of 1 )
I agree. Here's the link:
subject: stop parent process
It's not a secret anymore!