procclose.c revision 3f54fd611f536639ec30dd53c48e5ec1897cc7d9
/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1985-2011 AT&T Intellectual Property *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* Glenn Fowler <gsf@research.att.com> *
* David Korn <dgk@research.att.com> *
* Phong Vo <kpv@research.att.com> *
* *
***********************************************************************/
#pragma prototyped
/*
* Glenn Fowler
* AT&T Research
*
* close a proc opened by procopen()
* otherwise exit() status of process is returned
*/
#include "proclib.h"
int
{
int pid;
int flags = 0;
int status = -1;
if (p)
{
if (p->rfd >= 0)
if (p->flags & PROC_ORPHAN)
status = 0;
else
{
if (p->flags & PROC_ZOMBIE)
{
/*
* process may leave a zombie behind
* give it a chance to do that but
* don't hang waiting for it
*/
sleep(1);
}
if (!(p->flags & PROC_FOREGROUND))
status = 0;
if (!(p->flags & PROC_FOREGROUND))
sigcritical(0);
else
{
#if defined(SIGCHLD)
#if _lib_sigprocmask
#else
#if _lib_sigsetmask
sigsetmask(p->mask);
#else
#endif
#endif
#endif
}
}
procfree(p);
}
else
return status;
}