-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Interactive mode is unuseable #73
Comments
I came here to report the same issue. I have mine working now // Protocol OK
if (index >= 0)
{
if (g_commands[index].callback)
{
g_commands[index].callback(&proto);
if (proto.response)
{
if(msg->sender_id > 3){
SEND_TO_SENDER(msg->sender_id, proto.response, proto.response_size);
}else{
fprintf(stdout, "%s\n", proto.response);
}
if (g_verbose) printf("PROTOCOL: response '%s'\n", proto.response);
FREE(proto.response);
}
}
}
// Protocol error
else
{
if(msg->sender_id > 3){
SEND_TO_SENDER(msg->sender_id, g_error_messages[-index-1], strlen(g_error_messages[-index-1]));
}else{
fprintf(stdout, "%s\n", g_error_messages[-index-1]);
}
if (g_verbose) printf("PROTOCOL: error '%s'\n", g_error_messages[-index-1]);
} That is a bit hairy. But I do not think a socket file number can be less than 3, I just cannot find documentation for that. |
Looks like it is a POSIX thing. FDs 0, 1 and 2 are supposed to be standard streams: https://en.wikipedia.org/wiki/File_descriptor |
My workaround is just a workaround The problem of getting into an infinite loop I have not looked at, yet. |
The infinite loop issue is due to missing return (or break) statement after perror() is called in SEND_TO_SENDER function. See comments here: c69480e |
By convention, a shell based / launched application will use file descriptors 0, 1 & 2 for std in, out & err but this does not need to be the case and this behaviour can be changed. One should never assume that the first three file descriptors are used by in/out/err. I found this issue wieht continual This is a significant issue. Do we need to submit a PR to fix it? |
Check if command response is for fd 1.
Issuing commands in interactive mode results in error loop of
I tracked it down in the code to the fact that even in interactive mode the program wants to send the responses back using
socket_send( ) function, but using file descriptor "1" (STDOUT stream), which causes the socket lib to error out.
OS is Debian, from Stable to Sid, kernels : 6.1 and 6.7, arch amd64 and arm64.
The text was updated successfully, but these errors were encountered: