Fixed build.

This commit is contained in:
ha7ilm 2015-12-02 15:27:28 +01:00
parent 71e80ea809
commit c6e0a8f5c8
2 changed files with 8 additions and 8 deletions

View file

@ -79,7 +79,7 @@ int main(int argc, char* argv[])
{"address", required_argument, 0, 'a' }, {"address", required_argument, 0, 'a' },
{"decimation", required_argument, 0, 'd' }, {"decimation", required_argument, 0, 'd' },
{"bufsize", required_argument, 0, 'b' }, {"bufsize", required_argument, 0, 'b' },
{"method", required_argument, 0, 'm' } {"method", required_argument, 0, 'm' },
{"transition", required_argument, 0, 't' } {"transition", required_argument, 0, 't' }
}; };
c = getopt_long(argc, argv, "p:a:d:b:", long_options, &option_index); c = getopt_long(argc, argv, "p:a:d:b:", long_options, &option_index);
@ -201,7 +201,7 @@ int main(int argc, char* argv[])
case M_TD: case M_TD:
break; break;
case M_FASTDDC: case M_FASTDDC:
sprintf(main_subprocess_cmd_buf, subprocess_args_fastddc_1, decimation, tansition_bw); sprintf(main_subprocess_cmd_buf, subprocess_args_fastddc_1, decimation, transition_bw);
close(STDIN_FILENO); // redirect stdin to the stdin of the subprocess close(STDIN_FILENO); // redirect stdin to the stdin of the subprocess
main_subprocess_pid = run_subprocess( main_subprocess_cmd_buf, 0, pipe_s2m ); main_subprocess_pid = run_subprocess( main_subprocess_cmd_buf, 0, pipe_s2m );
break; break;
@ -303,8 +303,8 @@ int main(int argc, char* argv[])
pid_t run_subprocess(char* cmd, int* pipe_in, int* pipe_out) pid_t run_subprocess(char* cmd, int* pipe_in, int* pipe_out)
{ {
pid_t pid = fork(); pid_t pid = fork();
if(p < 0) return 0; //fork failed if(pid < 0) return 0; //fork failed
if(p==0) if(pid == 0)
{ {
//We're the subprocess //We're the subprocess
if(fcntl(pipe_in[1], F_SETPIPE_SZ, pipe_max_size) == -1) perror("Failed to F_SETPIPE_SZ in run_subprocess()"); if(fcntl(pipe_in[1], F_SETPIPE_SZ, pipe_max_size) == -1) perror("Failed to F_SETPIPE_SZ in run_subprocess()");
@ -318,8 +318,8 @@ pid_t run_subprocess(char* cmd, int* pipe_in, int* pipe_out)
close(pipe_out[0]); close(pipe_out[0]);
dup2(pipe_out[1], STDOUT_FILENO); dup2(pipe_out[1], STDOUT_FILENO);
} }
execl("/bin/bash","bash","-c",cmd, 0); execl("/bin/bash","bash","-c",cmd, NULL);
error_exit(MSG_START "run_subprocess failed to execute command") error_exit(MSG_START "run_subprocess failed to execute command");
} }
else return pid; else return pid;
} }

4
ddcd.h
View file

@ -32,7 +32,7 @@ void error_exit(const char* why);
void print_exit(const char* why); void print_exit(const char* why);
void print_client(client_t* client, const char* what); void print_client(client_t* client, const char* what);
int proc_exists(pid_t pid); int proc_exists(pid_t pid);
void run_subprocess(char* cmd, int* pipe_in, int* pipe_out); pid_t run_subprocess(char* cmd, int* pipe_in, int* pipe_out);
void maxfd(int* maxfd, int fd); void maxfd(int* maxfd, int fd);
typedef enum ddc_method_e typedef enum ddc_method_e
@ -47,7 +47,7 @@ const char subprocess_cmd_td[] = "csdr "
#else #else
"shift_unroll_cc" "shift_unroll_cc"
#endif #endif
" --pipe %d,%d | csdr fir_decimate_cc %d %g" }; " --pipe %d,%d | csdr fir_decimate_cc %d %g";
const char subprocess_args_fastddc_1[] = "csdr fastddc_fwd_cc %d %g"; const char subprocess_args_fastddc_1[] = "csdr fastddc_fwd_cc %d %g";
const char subprocess_args_fastddc_2[] = "csdr fastddc_inv_cc %d --pipe %d,%d %g"; const char subprocess_args_fastddc_2[] = "csdr fastddc_inv_cc %d --pipe %d,%d %g";