CDT Debug not reading EOF from console [message #1850159] |
Fri, 18 February 2022 11:50 |
Giuliano Lotta Messages: 9 Registered: June 2016 |
Junior Member |
|
|
Hi all!
Using Eclipse 2021.09 + CDT 10.5 + Ubuntu 20.04
when in debug of a CLI program, I cannot send any EOF (ctrl+D) to the program by the console.
Iit seems the the options "Connect process input & output to a terminal" that was proposed to fix the bugs many years ago, is NO MORE available in the config menu of Eclipse/CDT (is it?) ...
so I cannot found any workaround ...
Reading with a read() and getchar() completely IGNORE the ctrl-D...
KINDLY ask:
Are you facing the same problems during debug in CDT ?
Is there a workaround for my configuration, to send and EOF to the console during debug operations ?
Here an example Both reading with getchar and read DO return only after pressing enter, BUT if I press ctrl-D, the trace debug is lost, and the control never returns to the debug window, even i I enter Enter after having pressed ctrl-D... Seems that ctrl-D on the console terminal gets the console stucked ...
int position = 0; // writing buffer position
int ch;
ch = getchar();
//ch = read(STDIN_FILENO,&ch,1);
while (ch != EOF) {
(*buffer)[position] = (char) ch;
position++;
//printf("ch = %d\n", ch);
if (buf_len == position) { // buffer full ? double size!
buf_len *= 2;
*buffer = realloc(*buffer, buf_len);
if (buffer == NULL) {
perror("malloc()");
exit(EXIT_FAILURE);
}
}
//ch = read(STDIN_FILENO,&ch,1);
ch = read(STDIN_FILENO, &ch, sizeof(ch));
}
return position;
BR
Giuliano
[Updated on: Sat, 19 February 2022 09:28] Report message to a moderator
|
|
|
|
Re: CDT Debug not reading EOF from console [message #1850172 is a reply to message #1850162] |
Sat, 19 February 2022 09:33 |
Giuliano Lotta Messages: 9 Registered: June 2016 |
Junior Member |
|
|
Thanks for your reply
I checked and and both the functions getchar() and read() (sorry, I mispelled scanf in the first message... edited)
Both getchar() and read() do NOT return if I press ctrl-d .. ever worst the both do return if I press Enter, but both do NOR return if I press ctrl-D, and the consolle do not get back the control to the debug windows, even if I _then_ press Enter....
Here an example:
int position = 0; // writing buffer position
int ch;
ch = getchar();
//ch = read(STDIN_FILENO,&ch,1);
while (ch != EOF) {
(*buffer)[position] = (char) ch;
position++;
//printf("ch = %d\n", ch);
if (buf_len == position) { // buffer full ? double size!
buf_len *= 2;
*buffer = realloc(*buffer, buf_len);
if (buffer == NULL) {
perror("malloc()");
exit(EXIT_FAILURE);
}
}
//ch = read(STDIN_FILENO,&ch,1);
ch = read(STDIN_FILENO, &ch, sizeof(ch));
}
return position;
|
|
|
|
|
|
|
|
Re: CDT Debug not reading EOF from console [message #1850184 is a reply to message #1850180] |
Sun, 20 February 2022 15:28 |
David Vavra Messages: 1426 Registered: October 2012 |
Senior Member |
|
|
program outside Eclispe works
Sure if you change it but the one you posted will go into an
infinite loop once it enters the while (ch != EOF) block as ch
can never be equal to EOF past that point because the read
at the end of the block ch = read(STDIN_FILENO, &ch, sizeof(ch)))
will never return EOF.
while (ch != EOF) {
: :
ch = read(STDIN_FILENO, &ch, sizeof(ch));
}
[Updated on: Sun, 20 February 2022 15:28] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.04321 seconds