私はc#とStandardoutputRedirectを使用してプロセスの出力を文字列で取得していますが、プロセスがまだ出力を待っているにもかかわらず、プログラムが出力を返さないことがあるという問題があります。出力がない場合は、プログラムを続行しますか??
これが私のコードです
Process tcpdump = new Process();
tcpdump.StartInfo.FileName= "/usr/sbin/tcpdump";
tcpdump.StartInfo.CreateNoWindow = true;
tcpdump.StartInfo.Arguments = " -i en1 -c 10 -nn tcp and src host " + ip + " and port " + ports[i];
tcpdump.StartInfo.UseShellExecute = false;
tcpdump.StartInfo.RedirectStandardOutput = true;
tcpdump.Start();
tcpdump.WaitForExit(3000);
string tcpdump_output = tcpdump.StandardOutput.ReadToEnd(); // at this part the programs waits for an output