忍者ブログ

HITORIGOTO

哀戦士のオンラインメモ帳。 忍者ツールズって15年前にお世話になってたけど今も 残っててびっくりした。

system関数のエラー発生時のログ取得方法

×

[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。

system関数のエラー発生時のログ取得方法

#include <stdio.h>
#include <stdlib.h> // system(), WEXITSTATUS

bool doSystem(const char* command) {
int ret = system(command);
if (ret == -1) {
fprintf(stderr, "ERROR: Cannot execute [%s]\n", command);
return false;
}

int exitStatus = WEXITSTATUS(ret);
if (exitStatus != 0) {
fprintf(stderr, "ERROR: [%s] returns error %d\n", command, exitStatus);
return false;
}

return true;
}



Linux の system 関数で任意のプログラムを実行する|まくろぐ (maku.blog)
PR

コメント

プロフィール

HN:
哀戦士
性別:
非公開

P R