File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed
Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -1631,7 +1631,7 @@ PHP_FUNCTION(pcntl_setns)
16311631
16321632 pid = pid_is_null ? getpid () : pid ;
16331633 fd = syscall (SYS_pidfd_open , pid , 0 );
1634- if (errno ) {
1634+ if (fd == -1 ) {
16351635 PCNTL_G (last_error ) = errno ;
16361636 switch (errno ) {
16371637 case EINVAL :
@@ -1657,11 +1657,12 @@ PHP_FUNCTION(pcntl_setns)
16571657 RETURN_FALSE ;
16581658 }
16591659 ret = setns (fd , (int )nstype );
1660+ int setns_errno = errno ;
16601661 close (fd );
16611662
16621663 if (ret == -1 ) {
1663- PCNTL_G (last_error ) = errno ;
1664- switch (errno ) {
1664+ PCNTL_G (last_error ) = setns_errno ;
1665+ switch (setns_errno ) {
16651666 case ESRCH :
16661667 zend_argument_value_error (1 , "process no longer available (" ZEND_LONG_FMT ")" , pid );
16671668 RETURN_THROWS ();
@@ -1671,11 +1672,11 @@ PHP_FUNCTION(pcntl_setns)
16711672 RETURN_THROWS ();
16721673
16731674 case EPERM :
1674- php_error_docref (NULL , E_WARNING , "Error %d: No required capability for this process" , errno );
1675+ php_error_docref (NULL , E_WARNING , "Error %d: No required capability for this process" , setns_errno );
16751676 break ;
16761677
16771678 default :
1678- php_error_docref (NULL , E_WARNING , "Error %d" , errno );
1679+ php_error_docref (NULL , E_WARNING , "Error %d" , setns_errno );
16791680 }
16801681 RETURN_FALSE ;
16811682 } else {
You can’t perform that action at this time.
0 commit comments