mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
Merged revisions 78527,78550 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r78527 | gregory.p.smith | 2010-02-28 17:22:39 -0800 (Sun, 28 Feb 2010) | 4 lines Issue #7242: On Solaris 9 and earlier calling os.fork() from within a thread could raise an incorrect RuntimeError about not holding the import lock. The import lock is now reinitialized after fork. ........ r78550 | gregory.p.smith | 2010-02-28 22:01:02 -0800 (Sun, 28 Feb 2010) | 2 lines Fix test to be skipped on windows. ........
This commit is contained in:
parent
c78d79ce30
commit
24cec9fe07
4 changed files with 72 additions and 15 deletions
|
@ -3723,14 +3723,18 @@ static PyObject *
|
|||
posix_fork1(PyObject *self, PyObject *noargs)
|
||||
{
|
||||
pid_t pid;
|
||||
int result;
|
||||
int result = 0;
|
||||
_PyImport_AcquireLock();
|
||||
pid = fork1();
|
||||
result = _PyImport_ReleaseLock();
|
||||
if (pid == 0) {
|
||||
/* child: this clobbers and resets the import lock. */
|
||||
PyOS_AfterFork();
|
||||
} else {
|
||||
/* parent: release the import lock. */
|
||||
result = _PyImport_ReleaseLock();
|
||||
}
|
||||
if (pid == -1)
|
||||
return posix_error();
|
||||
if (pid == 0)
|
||||
PyOS_AfterFork();
|
||||
if (result < 0) {
|
||||
/* Don't clobber the OSError if the fork failed. */
|
||||
PyErr_SetString(PyExc_RuntimeError,
|
||||
|
@ -3752,14 +3756,18 @@ static PyObject *
|
|||
posix_fork(PyObject *self, PyObject *noargs)
|
||||
{
|
||||
pid_t pid;
|
||||
int result;
|
||||
int result = 0;
|
||||
_PyImport_AcquireLock();
|
||||
pid = fork();
|
||||
result = _PyImport_ReleaseLock();
|
||||
if (pid == 0) {
|
||||
/* child: this clobbers and resets the import lock. */
|
||||
PyOS_AfterFork();
|
||||
} else {
|
||||
/* parent: release the import lock. */
|
||||
result = _PyImport_ReleaseLock();
|
||||
}
|
||||
if (pid == -1)
|
||||
return posix_error();
|
||||
if (pid == 0)
|
||||
PyOS_AfterFork();
|
||||
if (result < 0) {
|
||||
/* Don't clobber the OSError if the fork failed. */
|
||||
PyErr_SetString(PyExc_RuntimeError,
|
||||
|
@ -3877,11 +3885,12 @@ posix_forkpty(PyObject *self, PyObject *noargs)
|
|||
|
||||
_PyImport_AcquireLock();
|
||||
pid = forkpty(&master_fd, NULL, NULL, NULL);
|
||||
if (pid == 0)
|
||||
PyOS_AfterFork();
|
||||
|
||||
result = _PyImport_ReleaseLock();
|
||||
if (pid == -1)
|
||||
return posix_error();
|
||||
if (pid == 0)
|
||||
PyOS_AfterFork();
|
||||
if (result < 0) {
|
||||
/* Don't clobber the OSError if the fork failed. */
|
||||
PyErr_SetString(PyExc_RuntimeError,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue