@@ -198,7 +198,7 @@ ZEND_GET_MODULE(pcntl)
198
198
199
199
static void pcntl_signal_handler (int );
200
200
static void pcntl_signal_dispatch ();
201
-
201
+
202
202
void php_register_signal_constants (INIT_FUNC_ARGS )
203
203
{
204
204
@@ -234,7 +234,7 @@ void php_register_signal_constants(INIT_FUNC_ARGS)
234
234
REGISTER_LONG_CONSTANT ("SIGTERM" , (long ) SIGTERM , CONST_CS | CONST_PERSISTENT );
235
235
#ifdef SIGSTKFLT
236
236
REGISTER_LONG_CONSTANT ("SIGSTKFLT" ,(long ) SIGSTKFLT , CONST_CS | CONST_PERSISTENT );
237
- #endif
237
+ #endif
238
238
#ifdef SIGCLD
239
239
REGISTER_LONG_CONSTANT ("SIGCLD" , (long ) SIGCLD , CONST_CS | CONST_PERSISTENT );
240
240
#endif
@@ -484,7 +484,7 @@ static void php_pcntl_register_errno_constants(INIT_FUNC_ARGS)
484
484
}
485
485
486
486
static PHP_GINIT_FUNCTION (pcntl )
487
- {
487
+ {
488
488
memset (pcntl_globals , 0 , sizeof (* pcntl_globals ));
489
489
}
490
490
@@ -547,7 +547,7 @@ PHP_FUNCTION(pcntl_fork)
547
547
PCNTL_G (last_error ) = errno ;
548
548
php_error_docref (NULL TSRMLS_CC , E_WARNING , "Error %d" , errno );
549
549
}
550
-
550
+
551
551
RETURN_LONG ((long ) id );
552
552
}
553
553
/* }}} */
@@ -560,7 +560,7 @@ PHP_FUNCTION(pcntl_alarm)
560
560
561
561
if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "l" , & seconds ) == FAILURE )
562
562
return ;
563
-
563
+
564
564
RETURN_LONG ((long ) alarm (seconds ));
565
565
}
566
566
/* }}} */
@@ -576,7 +576,7 @@ PHP_FUNCTION(pcntl_waitpid)
576
576
577
577
if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "lz|l" , & pid , & z_status , & options ) == FAILURE )
578
578
return ;
579
-
579
+
580
580
convert_to_long_ex (& z_status );
581
581
582
582
status = Z_LVAL_P (z_status );
@@ -604,7 +604,7 @@ PHP_FUNCTION(pcntl_wait)
604
604
605
605
if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "z|l" , & z_status , & options ) == FAILURE )
606
606
return ;
607
-
607
+
608
608
convert_to_long_ex (& z_status );
609
609
610
610
status = Z_LVAL_P (z_status );
@@ -628,7 +628,7 @@ PHP_FUNCTION(pcntl_wait)
628
628
}
629
629
/* }}} */
630
630
631
- /* {{{ proto bool pcntl_wifexited(int status)
631
+ /* {{{ proto bool pcntl_wifexited(int status)
632
632
Returns true if the child status code represents a successful exit */
633
633
PHP_FUNCTION (pcntl_wifexited )
634
634
{
@@ -646,7 +646,7 @@ PHP_FUNCTION(pcntl_wifexited)
646
646
}
647
647
/* }}} */
648
648
649
- /* {{{ proto bool pcntl_wifstopped(int status)
649
+ /* {{{ proto bool pcntl_wifstopped(int status)
650
650
Returns true if the child status code represents a stopped process (WUNTRACED must have been used with waitpid) */
651
651
PHP_FUNCTION (pcntl_wifstopped )
652
652
{
@@ -664,7 +664,7 @@ PHP_FUNCTION(pcntl_wifstopped)
664
664
}
665
665
/* }}} */
666
666
667
- /* {{{ proto bool pcntl_wifsignaled(int status)
667
+ /* {{{ proto bool pcntl_wifsignaled(int status)
668
668
Returns true if the child status code represents a process that was terminated due to a signal */
669
669
PHP_FUNCTION (pcntl_wifsignaled )
670
670
{
@@ -682,7 +682,7 @@ PHP_FUNCTION(pcntl_wifsignaled)
682
682
}
683
683
/* }}} */
684
684
685
- /* {{{ proto int pcntl_wexitstatus(int status)
685
+ /* {{{ proto int pcntl_wexitstatus(int status)
686
686
Returns the status code of a child's exit */
687
687
PHP_FUNCTION (pcntl_wexitstatus )
688
688
{
@@ -700,7 +700,7 @@ PHP_FUNCTION(pcntl_wexitstatus)
700
700
}
701
701
/* }}} */
702
702
703
- /* {{{ proto int pcntl_wtermsig(int status)
703
+ /* {{{ proto int pcntl_wtermsig(int status)
704
704
Returns the number of the signal that terminated the process who's status code is passed */
705
705
PHP_FUNCTION (pcntl_wtermsig )
706
706
{
@@ -718,7 +718,7 @@ PHP_FUNCTION(pcntl_wtermsig)
718
718
}
719
719
/* }}} */
720
720
721
- /* {{{ proto int pcntl_wstopsig(int status)
721
+ /* {{{ proto int pcntl_wstopsig(int status)
722
722
Returns the number of the signal that caused the process to stop who's status code is passed */
723
723
PHP_FUNCTION (pcntl_wstopsig )
724
724
{
@@ -754,19 +754,19 @@ PHP_FUNCTION(pcntl_exec)
754
754
char * path ;
755
755
int path_len ;
756
756
ulong key_num ;
757
-
758
- if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "s |aa" , & path , & path_len , & args , & envs ) == FAILURE ) {
757
+
758
+ if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "p |aa" , & path , & path_len , & args , & envs ) == FAILURE ) {
759
759
return ;
760
760
}
761
-
761
+
762
762
if (ZEND_NUM_ARGS () > 1 ) {
763
763
/* Build argument list */
764
764
args_hash = HASH_OF (args );
765
765
argc = zend_hash_num_elements (args_hash );
766
-
766
+
767
767
argv = safe_emalloc ((argc + 2 ), sizeof (char * ), 0 );
768
768
* argv = path ;
769
- for ( zend_hash_internal_pointer_reset (args_hash ), current_arg = argv + 1 ;
769
+ for ( zend_hash_internal_pointer_reset (args_hash ), current_arg = argv + 1 ;
770
770
(argi < argc && (zend_hash_get_current_data (args_hash , (void * * ) & element ) == SUCCESS ));
771
771
(argi ++ , current_arg ++ , zend_hash_move_forward (args_hash )) ) {
772
772
@@ -784,9 +784,9 @@ PHP_FUNCTION(pcntl_exec)
784
784
/* Build environment pair list */
785
785
envs_hash = HASH_OF (envs );
786
786
envc = zend_hash_num_elements (envs_hash );
787
-
787
+
788
788
envp = safe_emalloc ((envc + 1 ), sizeof (char * ), 0 );
789
- for ( zend_hash_internal_pointer_reset (envs_hash ), pair = envp ;
789
+ for ( zend_hash_internal_pointer_reset (envs_hash ), pair = envp ;
790
790
(envi < envc && (zend_hash_get_current_data (envs_hash , (void * * ) & element ) == SUCCESS ));
791
791
(envi ++ , pair ++ , zend_hash_move_forward (envs_hash )) ) {
792
792
switch (return_val = zend_hash_get_current_key_ex (envs_hash , & key , & key_length , & key_num , 0 , NULL )) {
@@ -802,13 +802,13 @@ PHP_FUNCTION(pcntl_exec)
802
802
803
803
convert_to_string_ex (element );
804
804
805
- /* Length of element + equal sign + length of key + null */
805
+ /* Length of element + equal sign + length of key + null */
806
806
pair_length = Z_STRLEN_PP (element ) + key_length + 2 ;
807
807
* pair = emalloc (pair_length );
808
- strlcpy (* pair , key , key_length );
808
+ strlcpy (* pair , key , key_length );
809
809
strlcat (* pair , "=" , pair_length );
810
810
strlcat (* pair , Z_STRVAL_PP (element ), pair_length );
811
-
811
+
812
812
/* Cleanup */
813
813
if (return_val == HASH_KEY_IS_LONG ) efree (key );
814
814
}
@@ -818,7 +818,7 @@ PHP_FUNCTION(pcntl_exec)
818
818
PCNTL_G (last_error ) = errno ;
819
819
php_error_docref (NULL TSRMLS_CC , E_WARNING , "Error has occurred: (errno %d) %s" , errno , strerror (errno ));
820
820
}
821
-
821
+
822
822
/* Cleanup */
823
823
for (pair = envp ; * pair != NULL ; pair ++ ) efree (* pair );
824
824
efree (envp );
@@ -831,7 +831,7 @@ PHP_FUNCTION(pcntl_exec)
831
831
}
832
832
833
833
efree (argv );
834
-
834
+
835
835
RETURN_FALSE ;
836
836
}
837
837
/* }}} */
@@ -880,19 +880,19 @@ PHP_FUNCTION(pcntl_signal)
880
880
}
881
881
RETURN_TRUE ;
882
882
}
883
-
883
+
884
884
if (!zend_is_callable (handle , 0 , & func_name TSRMLS_CC )) {
885
885
PCNTL_G (last_error ) = EINVAL ;
886
886
php_error_docref (NULL TSRMLS_CC , E_WARNING , "%s is not a callable function name error" , func_name );
887
887
efree (func_name );
888
888
RETURN_FALSE ;
889
889
}
890
890
efree (func_name );
891
-
891
+
892
892
/* Add the function name to our signal table */
893
893
zend_hash_index_update (& PCNTL_G (php_signal_table ), signo , (void * * ) & handle , sizeof (zval * ), (void * * ) & dest_handle );
894
894
if (dest_handle ) zval_add_ref (dest_handle );
895
-
895
+
896
896
if (php_signal4 (signo , pcntl_signal_handler , (int ) restart_syscalls , 1 ) == SIG_ERR ) {
897
897
PCNTL_G (last_error ) = errno ;
898
898
php_error_docref (NULL TSRMLS_CC , E_WARNING , "Error assigning signal ");
@@ -1029,7 +1029,7 @@ static void pcntl_sigwaitinfo(INTERNAL_FUNCTION_PARAMETERS, int timedwait) /* {{
1029
1029
}
1030
1030
1031
1031
/*
1032
- * sigtimedwait and sigwaitinfo can return 0 on success on some
1032
+ * sigtimedwait and sigwaitinfo can return 0 on success on some
1033
1033
* platforms, e.g. NetBSD
1034
1034
*/
1035
1035
if (!signo && siginfo .si_signo ) {
@@ -1077,7 +1077,7 @@ static void pcntl_sigwaitinfo(INTERNAL_FUNCTION_PARAMETERS, int timedwait) /* {{
1077
1077
EMPTY_SWITCH_DEFAULT_CASE ();
1078
1078
}
1079
1079
}
1080
-
1080
+
1081
1081
RETURN_LONG (signo );
1082
1082
}
1083
1083
/* }}} */
@@ -1107,12 +1107,12 @@ PHP_FUNCTION(pcntl_getpriority)
1107
1107
long who = PRIO_PROCESS ;
1108
1108
long pid = getpid ();
1109
1109
int pri ;
1110
-
1110
+
1111
1111
if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "|ll" , & pid , & who ) == FAILURE ) {
1112
1112
RETURN_FALSE ;
1113
1113
}
1114
1114
1115
- /* needs to be cleared, since any returned value is valid */
1115
+ /* needs to be cleared, since any returned value is valid */
1116
1116
errno = 0 ;
1117
1117
1118
1118
pri = getpriority (who , pid );
@@ -1172,7 +1172,7 @@ PHP_FUNCTION(pcntl_setpriority)
1172
1172
}
1173
1173
RETURN_FALSE ;
1174
1174
}
1175
-
1175
+
1176
1176
RETURN_TRUE ;
1177
1177
}
1178
1178
/* }}} */
@@ -1205,7 +1205,7 @@ static void pcntl_signal_handler(int signo)
1205
1205
{
1206
1206
struct php_pcntl_pending_signal * psig ;
1207
1207
TSRMLS_FETCH ();
1208
-
1208
+
1209
1209
psig = PCNTL_G (spares );
1210
1210
if (!psig ) {
1211
1211
/* oops, too many signals for us to track, so we'll forget about this one */
@@ -1233,7 +1233,7 @@ void pcntl_signal_dispatch()
1233
1233
sigset_t mask ;
1234
1234
sigset_t old_mask ;
1235
1235
TSRMLS_FETCH ();
1236
-
1236
+
1237
1237
/* Mask all signals */
1238
1238
sigfillset (& mask );
1239
1239
sigprocmask (SIG_BLOCK , & mask , & old_mask );
@@ -1249,7 +1249,7 @@ void pcntl_signal_dispatch()
1249
1249
1250
1250
queue = PCNTL_G (head );
1251
1251
PCNTL_G (head ) = NULL ; /* simple stores are atomic */
1252
-
1252
+
1253
1253
/* Allocate */
1254
1254
1255
1255
while (queue ) {
@@ -1274,7 +1274,7 @@ void pcntl_signal_dispatch()
1274
1274
1275
1275
/* Re-enable queue */
1276
1276
PCNTL_G (processing_signal_queue ) = 0 ;
1277
-
1277
+
1278
1278
/* return signal mask to previous state */
1279
1279
sigprocmask (SIG_SETMASK , & old_mask , NULL );
1280
1280
}
0 commit comments