Skip to content

Commit 3881b5f

Browse files
committed
Do not try to send responses to stdout
Signed-off-by: falkTX <[email protected]>
1 parent d16c79a commit 3881b5f

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

src/mod-host.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@
3333
#include <stdlib.h>
3434
#include <fcntl.h>
3535
#include <string.h>
36-
#include <unistd.h>
3736
#include <getopt.h>
3837
#include <jack/jack.h>
3938
#include <signal.h>
4039

4140
#ifndef SKIP_READLINE
41+
#include <unistd.h>
4242
#include <readline/readline.h>
4343
#include <readline/history.h>
4444
#endif

src/protocol.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
#include <stdio.h>
2626
#include <string.h>
2727

28+
#ifndef SKIP_READLINE
29+
#include <unistd.h>
30+
#endif
31+
2832
#include "protocol.h"
2933
#include "utils.h"
3034

@@ -216,7 +220,10 @@ void protocol_parse(msg_t *msg)
216220
g_commands[index].callback(&proto);
217221
if (proto.response)
218222
{
219-
SEND_TO_SENDER(msg->sender_id, proto.response, proto.response_size);
223+
#ifndef SKIP_READLINE
224+
if (msg->sender_id != STDOUT_FILENO)
225+
#endif
226+
socket_send(msg->sender_id, proto.response, proto.response_size+1);
220227
if (g_verbose) printf("PROTOCOL: response '%s'\n", proto.response);
221228

222229
FREE(proto.response);
@@ -226,7 +233,10 @@ void protocol_parse(msg_t *msg)
226233
// Protocol error
227234
else
228235
{
229-
SEND_TO_SENDER(msg->sender_id, g_error_messages[-index-1], strlen(g_error_messages[-index-1]));
236+
#ifndef SKIP_READLINE
237+
if (msg->sender_id != STDOUT_FILENO)
238+
#endif
239+
socket_send(msg->sender_id, g_error_messages[-index-1], strlen(g_error_messages[-index-1])+1);
230240
if (g_verbose) printf("PROTOCOL: error '%s'\n", g_error_messages[-index-1]);
231241
}
232242

src/protocol.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,6 @@
5656
#define MESSAGE_FEW_ARGUMENTS "few arguments"
5757
#define MESSAGE_INVALID_ARGUMENT "invalid argument"
5858

59-
// defines the function to send responses to sender
60-
#define SEND_TO_SENDER(id,msg,len) socket_send((id),(msg),(len)+1)
61-
6259

6360
/*
6461
************************************************************************************************************************

0 commit comments

Comments
 (0)