I want to debug my cgi script (C++) from IDE, so I would like to create a "debug mode": read file from disk, push it to own stdin, set some environment variables, that correspond this file and run the rest of the script as it was called by the web server. Is it possible and if it is, then how can I do that?
It is possible to send input text to a running process without running the screen utility, or any other fancy utility. And it can be done by sending this input text to the process' standard input "file" /proc/PID#/fd/0 . However, the input text needs to be sent in a special way to be read by the process.
you can just fclose(stdin), it will call close() on the file handle.
You can't "push to own stdin", but you can redirect a file to your own stdin.
freopen("myfile.txt","r",stdin);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With