alpine 3.6
obsolete weakness #11

2

Weakness Breakdown


Definition:

An obsolete weakness occurs when someone uses deprecated or obsolete functions when building a system. As a programming language evolves, some functions occasionally become obsolete.

Warning code(s):

These functions are considered obsolete on most systems, and very non-portable.

File Name:

R/src/R-3.3.3/src/library/tools/src/signals.c

Context:

The highlighted line of code below is the trigger point of this particular Alpine 3.6 obsolete weakness.

  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, a copy is available at
 *  https://www.R-project.org/Licenses/
 */

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include "tools.h"
#include <signal.h> // C99

#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#endif

SEXP ps_kill(SEXP spid, SEXP ssignal)
{
    SEXP sspid, sres;
    int *pid, *res, signal = asInteger(ssignal);
    PROTECT(sspid = coerceVector(spid, INTSXP));
    unsigned int ns = LENGTH(sspid);
    PROTECT(sres = allocVector(LGLSXP, ns));
    pid = INTEGER(sspid);
    res = INTEGER(sres);
#if !defined(_WIN32) && !defined(HAVE_KILL)
    warning(_("pskill() is not supported on this platform"));
#endif
    if(signal != NA_INTEGER) {
	for (int i = 0; i < ns; i++) {
#ifdef _WIN32
	    HANDLE hProc = OpenProcess(PROCESS_TERMINATE, FALSE, pid[i]);
	    if (hProc) {
                TerminateProcess(hProc, 1);
                CloseHandle(hProc);
	    }
#elif defined(HAVE_KILL)
	    if (pid[i] <= 0) continue;
	    if (pid[i] != NA_INTEGER) res[i] = kill(pid[i], signal);
#endif
	}
    }
    UNPROTECT(2);
    return sres;
} 

The registered trademark Linux® is used pursuant to a sublicense from the Linux Foundation, the exclusive licensee of Linus Torvalds, owner of the mark on a world­wide basis.