0

これは私のコードです(これは単なる例です)

int a = system("pwd");
printf("pwd with return: %d\n", a);
cout << "errno is " << errno << "\n";

signal(SIGCHLD, SIG_IGN);

a = system("pwd");
printf("pwd with return: %d\n", a);
cout << "errno is " << errno << "\n";

「SIGCHLD」の前後にシステムコールを使用して「pwd」コマンドを実行すると、 2 つの異なる結果が得られます。

<actual path>
pwd with return: 0
errno is 0
<actual path>
pwd with return: -1
errno is 10

どちらの場合も、コマンドは適切に実行されます。

なぜsignal(SIGCHLD, SIG_IGN);この問題が発生するのですか? それを回避する方法はありますか?

4

0 に答える 0