Passing End of Transmission (Ctrl + D) character in Eclipse CDT console

后端 未结 4 920
一生所求
一生所求 2020-11-30 08:58

I have a C++ application, to which i need to send an End of Transmission signal.

I can do a Ctrl+D on the console, but when I try that within

4条回答
  •  心在旅途
    2020-11-30 09:25

    One way you might consider sending ctrl+d to the console is by doing a little BASH injection in your program arguments. appending something like "& sleep 10 && echo -e '\x04\c' > /dev/stdin" for example will wait 10 seconds before sending the ctrl-D command. though you could easily modify it for some other non-timebased condition as well. In addition, you could open /dev/stdin from your C++ program as a file, then write the value 0x04 into it then flush to achieve the same effect from your program.

提交回复
热议问题