Hitting enter key via bash redirection

Viewed 14

How can I end inputting text to a process that reads from standard-in in one console from another console? - what is usually done by hitting the enter key.

This is different to what is answered in this suggested duplicate post, because my program is already running and already reading from std:in.

Console 1: a C++ program reads from std::cin aslong the user does not hit enter (usual behavior).

Console 2: in a plain console I found out that I can send any text to the process in Console 1 by

echo "some text" >> /proc/18672/fd/0

(which simply writes to the standard-in of my process, which has the PID 18672).

This works but an important step is missing:

How can I end inputting e.g. "some text" from Console 2, or, how can I simulate hitting the enter-key for Console 1 from Console 2?

Using new line escapes, such as "\n" does not work.

0 Answers
Related