/*+++++++++++++++++++++++++ FUNCTION DESCRIPTION ++++++++++++++++++++++++++++++
*
* NAME : UTL_FindProc FOR UNIX
*
* DESCRIPTION : Finds out if a given process is still running
* on the system.
*
* COMPLETION
* STATUS : UTL__NORMAL
* Success; Service has completed succesfully.
*
* UTL__INVPID
* Failure; Invalid process number given.
*
* UTL__PIDNOTFOUND
* Failure; Process is not active.
*
*-----------------------------------------------------------------------------
*/
MSG_ID_T UTL_FindProc(
pid_t pd) /*- input: process id to find -*/
{
MSG_ID_T sts; /*- return status of findproc -*/
int rtn; /*- return status of getprio -*/
#ifdef SUN
pcparms_t pcparms;
#endif
sts = UTL__NORMAL;
if (pd < UTL_PRC_2)
{
sts = UTL__INVPID;
}
else
{
if (pd != getpid())
{
errno = 0;
rtn = 0;
#ifndef AIX
#ifdef SUN /* important to administe the processes */
pcparms.pc_cid = PC_CLNULL;
rtn = priocntl(P_PID, pd, PC_GETPARMS,(char *) &pcparms);
#else
rtn = getpriority(PRIO_PROCESS, pd);
#endif /* SUN */
#else
rtn = getpri(pd);
#endif /* AIX */
if (rtn == -1)
{
if (errno == ESRCH)
{
sts = UTL__PIDNOTFOUND;
}
else if ((errno != NULL) && (errno != EPERM))
{
ERR_SignalError("Utilities Package",
"UTL_FindProc fct",
errno) ;
exit( EXIT_FAILURE );
}
}
}
}