I am calling a script from with another script and reading its output one line at a time (using <childscript> | while read line) in the parent script. If the output exceeds a predefined number of lines I want to kill the child shell from within the parent shell.
I decided to print the process ID using $$ in the child shell so that parent shell can read it and send kill signal to it. That I am able to, however it says process doesn't exist.
Can anybody suggest me a better way to do things. Note I need to do cleanup in child script (so I am using trap) and also this has to be done on sh and not any other shell, not even bash.
Thanks for helping.