I have been tossing for this thing for a day today!
I use the middleware written in Java to start a sub-process based on the user's needs. This process is written in C ++ and is easy to use log4cxx to record logs for analysis. This process runs independently from the control terminal without any problems. However, once the Java promoter process is used to start the process, the sub-process will not be blocked as soon as it is started, then, the sub-process can be executed smoothly, which may take several minutes to two hours.
The first time I encountered such a problem, it was very strange. After repeated tests and the omnipotent google help, I found the reason why Java called external programs to suspend. log4cxx was originally the culprit, because it redirects a large amount of log information to the console, because the Java Process is not clearedProgramAs a result, the program remains waiting.
There are two solutions to this problem:
- As mentioned above, when Java starts an external program and causes thread blocking, you can consider using two threads to clear the two input streams obtained by process at the same time;
- You can directly redirect log4cxx to the console to cancel the log message, which can be achieved through the log4cxx configuration file.
After the problem is solved, the world becomes beautiful again!