stdout
CプログラムでLinuxコマンドを実行し、プログラムでこのコマンドから読み取り(解析)したい。以下のコードは機能しますが、文字列とバイトの読み取り制限に加えて、コマンドの実行時間を制限する方法がわかりません。何か案は?
FILE *ps_pipe;
int bytes_read;
int nbytes = 100;
char *my_string=NULL;
char message[1024];
message=sprintf(message,"any command here");
ps_pipe = popen (message, "r");
my_string = (char *) malloc (nbytes + 1);
bytes_read = getdelim (&my_string, &nbytes, "delimiter_word", ps_pipe);
pclose(ps_pipe);
free(my_string);