C and C++ Binaries


CONCURRENCY.BADFUNC.PTHREAD_KILL : pthread_killの使用

要旨

A use of pthread_kill(), which terminates the entire process. Some signal arguments to pthread_kill() can terminate the entire process rather than just a single thread, which may not be the intention.

プロパティ

クラス名 Use of pthread_kill
日本語クラス名 pthread_killの使用
クラス分類 信頼性 (reliability)
ニーモニック CONCURRENCY.BADFUNC.PTHREAD_KILL
カテゴリー
CWE CWE:676 Use of Potentially Dangerous Function
CERT-C CERT-C:POS44-C Do not use signals to terminate threads
対応言語 C および C++ で利用可能です。
有効/無効設定 このワーニングクラスのチェックはデフォルトで無効になっています。チェックを有効にするにはプロジェクト設定ファイル (configuration file)に以下の WARNING_FILTER ルールを追加してください。
WARNING_FILTER += allow class="Use of pthread_kill"

#include <pthread.h>
#include <signal.h>

int stop_thread(pthread_t thread, int i){
    if (i>0){
        return pthread_kill(thread, SIGTERM); /* 'Use of pthread_kill' warning issued here */
    }
    else {
        return pthread_cancel(thread);                                /* pthread_cancel() terminates a single thread */
    }
}

関連のある設定ファイルパラメータ

設定ファイルの以下のパラメータがこのワーニングクラスのチェックに影響します。