Reputation: 1433
I have a Process object, which i need to terminate at a given point in time. I tried Process.destroy(), but this does not effectively let the process to release the port it was using, due to which i cannot use it. All i need to do is to send a "Ctrl + C" to the 'Process' which already has a shutdown hook written in it, which takes care of releasing any resources.
How can i do this.
I am Using Windows
Upvotes: 3
Views: 2029
Reputation: 21510
You can send a command using taskkill like explained in this article.
Upvotes: 0
Reputation: 200138
Counting on shutdown hooks for regular operation is a broken approach. You must design your application to provide its own protocol by which it can receive a shutdown signal. This is the only way to write a solid multiplatform application, where by "multiplatform" I also imply different versions of the same platform.
Upvotes: 2