I have a python code that has some inputs:
a = input("first input:")
b = input("second input:")
I run it from java:
Process process = new ProcessBuilder("python3", scriptPath).start();
but running from python is also suitable for me.
Is it possible to catch signal from python process when it waits for input and handle it somehow? For instance, on the first input I want to write some text to process.getOutputStream() and on the second input I want to kill process.
I found that there is SIGTTIN signal for terminal input. And I tried to do it in python:
def interrupted(signum, frame):
exit()
signal.signal(signal.SIGTTIN, interrupted)
a = input()
but it did not work out.