зеркало из https://github.com/mozilla/pjs.git
Add support for inheritable fds on BeOS.
Bug #96331 r=arougthopher@lizardland.net
This commit is contained in:
Родитель
ef5d4646d4
Коммит
d86e4a346b
|
@ -312,6 +312,7 @@ struct protoent* getprotobynumber(int number);
|
|||
#define _MD_READ_DIR _MD_read_dir
|
||||
#define _MD_CLOSE_DIR _MD_close_dir
|
||||
#define _MD_MAKE_NONBLOCK _MD_make_nonblock
|
||||
#define _MD_SET_FD_INHERITABLE _MD_set_fd_inheritable
|
||||
#define _MD_INIT_FD_INHERITABLE _MD_init_fd_inheritable
|
||||
#define _MD_QUERY_FD_INHERITABLE _MD_query_fd_inheritable
|
||||
#define _MD_OPEN _MD_open
|
||||
|
|
|
@ -164,7 +164,7 @@ PR_IMPLEMENT(PRStatus) PR_SetFDInheritable(
|
|||
PRFileDesc *fd,
|
||||
PRBool inheritable)
|
||||
{
|
||||
#if defined(XP_UNIX) || defined(WIN32) || defined(XP_OS2)
|
||||
#if defined(XP_UNIX) || defined(WIN32) || defined(XP_OS2) || defined(XP_BEOS)
|
||||
/*
|
||||
* Only a non-layered, NSPR file descriptor can be inherited
|
||||
* by a child process.
|
||||
|
|
|
@ -118,18 +118,45 @@ _MD_make_nonblock (PRFileDesc *fd)
|
|||
|
||||
}
|
||||
|
||||
PRStatus
|
||||
_MD_set_fd_inheritable (PRFileDesc *fd, PRBool inheritable)
|
||||
{
|
||||
int rv;
|
||||
|
||||
rv = fcntl(fd->secret->md.osfd, F_SETFD, inheritable ? 0 : FD_CLOEXEC);
|
||||
if (-1 == rv) {
|
||||
PR_SetError(PR_UNKNOWN_ERROR, _MD_ERRNO());
|
||||
return PR_FAILURE;
|
||||
}
|
||||
return PR_SUCCESS;
|
||||
}
|
||||
|
||||
void
|
||||
_MD_init_fd_inheritable (PRFileDesc *fd, PRBool imported)
|
||||
{
|
||||
/* XXX this function needs to be implemented */
|
||||
fd->secret->inheritable = _PR_TRI_UNKNOWN;
|
||||
if (imported) {
|
||||
fd->secret->inheritable = _PR_TRI_UNKNOWN;
|
||||
} else {
|
||||
int flags = fcntl(fd->secret->md.osfd, F_GETFD, 0);
|
||||
if (flags == -1) {
|
||||
PR_SetError(PR_UNKNOWN_ERROR, _MD_ERRNO());
|
||||
return;
|
||||
}
|
||||
fd->secret->inheritable = (flags & FD_CLOEXEC) ?
|
||||
_PR_TRI_TRUE : _PR_TRI_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
_MD_query_fd_inheritable (PRFileDesc *fd)
|
||||
{
|
||||
/* XXX this function needs to be implemented */
|
||||
PR_ASSERT(0);
|
||||
int flags;
|
||||
|
||||
PR_ASSERT(_PR_TRI_UNKNOWN == fd->secret->inheritable);
|
||||
flags = fcntl(fd->secret->md.osfd, F_GETFD, 0);
|
||||
PR_ASSERT(-1 != flags);
|
||||
fd->secret->inheritable = (flags & FD_CLOEXEC) ?
|
||||
_PR_TRI_FALSE : _PR_TRI_TRUE;
|
||||
}
|
||||
|
||||
PRInt32
|
||||
|
|
Загрузка…
Ссылка в новой задаче