2009-04-25 04:58:15 +05:30
|
|
|
/*
|
2021-12-05 21:05:27 +05:30
|
|
|
* SPDX-FileCopyrightText: 2009 , Nicolas François
|
2009-04-25 04:58:15 +05:30
|
|
|
*
|
2021-12-05 21:05:27 +05:30
|
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
2009-04-25 04:58:15 +05:30
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#ident "$Id$"
|
|
|
|
|
|
|
|
#include "prototypes.h"
|
|
|
|
#include "defines.h"
|
|
|
|
|
|
|
|
int get_pid (const char *pidstr, pid_t *pid)
|
|
|
|
{
|
|
|
|
long long int val;
|
|
|
|
char *endptr;
|
|
|
|
|
|
|
|
errno = 0;
|
|
|
|
val = strtoll (pidstr, &endptr, 10);
|
|
|
|
if ( ('\0' == *pidstr)
|
|
|
|
|| ('\0' != *endptr)
|
|
|
|
|| (ERANGE == errno)
|
2009-05-01 02:42:33 +05:30
|
|
|
|| (/*@+longintegral@*/val != (pid_t)val)/*@=longintegral@*/) {
|
2009-04-25 04:58:15 +05:30
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2023-02-01 18:20:48 +05:30
|
|
|
*pid = val;
|
2009-04-25 04:58:15 +05:30
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|