static FILE *pipef;
+static int openPort(int port);
+
static void *data_output_thread(void *arg)
{
+ if (dataPort > 0)
+ {
+ data_socket = openPort(dataPort);
+ if (data_socket < 0) {
+ log_error("cannot open data port");
+ return;
+ }
+ data_file_out = fdopen(data_socket, "w");
+ if (data_file_out == NULL) {
+ log_system_error("fdopen(data,w)");
+ return;
+ }
+ if (fprintf(data_file_out, "ready\n") < 0 || fflush(data_file_out) != 0) {
+ log_system_error("cannot write 'ready' prompt to data stream");
+ return;
+ }
+ }
+
do
{
int linesRead = 0;
log_system_error("fopen(%s)", pname);
return -1;
}
+ if (verbose) {
+ log_message("pipe %s opened for read", pname);
+ }
return 0;
}
}
}
else if (is_command(line, "exit", &pid, app_pid, NULL, 0) == 0) {
- send_signal(pid, SIGHUP);
+ if (pid != -1) {
+ send_signal(pid, SIGHUP);
+ }
if (verbose && !global_stop) {
log_message("stop flag set (command_loop_thread)");
}
if (controlPort > 0) {
control_socket = openPort(controlPort);
if (control_socket < 0) {
+ log_error("cannot open control port");
exit(1);
}
ctrl_file_in = fdopen(control_socket, "r");
}
if (dataPort > 0) {
+ // data_output_thread will open the data port
+/*!!
data_socket = openPort(dataPort);
if (data_socket < 0) {
return 1;
log_system_error("cannot write 'ready' prompt to data stream");
return 1;
}
+*/
}
else {
data_file_out = stdout;
if (doinfo && (statPort > 0)) {
stat_socket = openPort(statPort);
if (stat_socket < 0) {
+ log_error("cannot open statistics port");
exit(1);
}
stat_file_out = fdopen(stat_socket, "w");
if (stat_file_out == NULL) {
log_system_error_and_exit("fdopen(stat,w)");
}
+ if (fprintf(stat_file_out, "ready\n") < 0 || fflush(stat_file_out) != 0) {
+ log_system_error("cannot write 'ready' prompt to statistics stream");
+ return;
+ }
}
pthread_t data_output_thread_id;