I need to terminate my child when parent exits abnormally. I found an answer in this below link for my requirement:
How can I cause a child process to exit when the parent does?
Answer from tomcri:
You can simply start a thread reading from System.in in the child process. If you are not writing to stdin of your child, nobody else will do and the thread will block "forever". But you will get an EOF (or an exception), if the parent process is killed or dies otherwise. So you can shutdown the child as well. (Child process started with java.lang.ProcessBuilder)
Actually, I tried to comment below this Answer but couldn't due to lack of enough reputation.
So my question is, how do I recognize the character in the stdin is EOF? In my program, I am reading data from stdin for some other purpose too. So I need to know when EOF/(chars comes when parent dies) somehow. stdin is filled with character = ÿ (hex = 0xFFFF). I read some pages like 'The highest possible valid code point is Ux10FFFF in Unicode'. So how do I check to exit?
My program is Windows C++ and supports Unicode characters. Is there any better way to understand this scenario?