Skip to content

Commit 99ce142

Browse files
committed
Some pcntl cleanup
Fix some indentation issues and make sure zpp is used consistently.
1 parent deb5226 commit 99ce142

File tree

1 file changed

+54
-42
lines changed

1 file changed

+54
-42
lines changed

ext/pcntl/pcntl.c

Lines changed: 54 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,10 @@ PHP_FUNCTION(pcntl_fork)
642642
{
643643
pid_t id;
644644

645+
if (zend_parse_parameters_none() == FAILURE) {
646+
return;
647+
}
648+
645649
id = fork();
646650
if (id == -1) {
647651
PCNTL_G(last_error) = errno;
@@ -658,10 +662,11 @@ PHP_FUNCTION(pcntl_alarm)
658662
{
659663
zend_long seconds;
660664

661-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &seconds) == FAILURE)
665+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &seconds) == FAILURE) {
662666
return;
667+
}
663668

664-
RETURN_LONG ((zend_long) alarm(seconds));
669+
RETURN_LONG((zend_long) alarm(seconds));
665670
}
666671
/* }}} */
667672

@@ -807,17 +812,17 @@ PHP_FUNCTION(pcntl_wait)
807812
Returns true if the child status code represents a successful exit */
808813
PHP_FUNCTION(pcntl_wifexited)
809814
{
810-
#ifdef WIFEXITED
811815
zend_long status_word;
812-
int int_status_word;
813816

814817
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &status_word) == FAILURE) {
815-
return;
818+
return;
816819
}
817820

818-
int_status_word = (int) status_word;
819-
if (WIFEXITED(int_status_word))
821+
#ifdef WIFEXITED
822+
int int_status_word = (int) status_word;
823+
if (WIFEXITED(int_status_word)) {
820824
RETURN_TRUE;
825+
}
821826
#endif
822827

823828
RETURN_FALSE;
@@ -828,18 +833,19 @@ PHP_FUNCTION(pcntl_wifexited)
828833
Returns true if the child status code represents a stopped process (WUNTRACED must have been used with waitpid) */
829834
PHP_FUNCTION(pcntl_wifstopped)
830835
{
831-
#ifdef WIFSTOPPED
832836
zend_long status_word;
833-
int int_status_word;
834837

835838
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &status_word) == FAILURE) {
836-
return;
839+
return;
837840
}
838841

839-
int_status_word = (int) status_word;
840-
if (WIFSTOPPED(int_status_word))
842+
#ifdef WIFSTOPPED
843+
int int_status_word = (int) status_word;
844+
if (WIFSTOPPED(int_status_word)) {
841845
RETURN_TRUE;
846+
}
842847
#endif
848+
843849
RETURN_FALSE;
844850
}
845851
/* }}} */
@@ -848,36 +854,37 @@ PHP_FUNCTION(pcntl_wifstopped)
848854
Returns true if the child status code represents a process that was terminated due to a signal */
849855
PHP_FUNCTION(pcntl_wifsignaled)
850856
{
851-
#ifdef WIFSIGNALED
852857
zend_long status_word;
853-
int int_status_word;
854858

855859
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &status_word) == FAILURE) {
856-
return;
860+
return;
857861
}
858862

859-
int_status_word = (int) status_word;
860-
if (WIFSIGNALED(int_status_word))
863+
#ifdef WIFSIGNALED
864+
int int_status_word = (int) status_word;
865+
if (WIFSIGNALED(int_status_word)) {
861866
RETURN_TRUE;
867+
}
862868
#endif
869+
863870
RETURN_FALSE;
864871
}
865872
/* }}} */
866873
/* {{{ proto bool pcntl_wifcontinued(int status)
867874
Returns true if the child status code represents a process that was resumed due to a SIGCONT signal */
868875
PHP_FUNCTION(pcntl_wifcontinued)
869876
{
870-
#ifdef HAVE_WCONTINUED
871877
zend_long status_word;
872-
int int_status_word;
873878

874879
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &status_word) == FAILURE) {
875-
return;
880+
return;
876881
}
877882

878-
int_status_word = (int) status_word;
879-
if (WIFCONTINUED(int_status_word))
883+
#ifdef HAVE_WCONTINUED
884+
int int_status_word = (int) status_word;
885+
if (WIFCONTINUED(int_status_word)) {
880886
RETURN_TRUE;
887+
}
881888
#endif
882889
RETURN_FALSE;
883890
}
@@ -888,15 +895,14 @@ PHP_FUNCTION(pcntl_wifcontinued)
888895
Returns the status code of a child's exit */
889896
PHP_FUNCTION(pcntl_wexitstatus)
890897
{
891-
#ifdef WEXITSTATUS
892898
zend_long status_word;
893-
int int_status_word;
894899

895900
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &status_word) == FAILURE) {
896-
return;
901+
return;
897902
}
898903

899-
int_status_word = (int) status_word;
904+
#ifdef WEXITSTATUS
905+
int int_status_word = (int) status_word;
900906
RETURN_LONG(WEXITSTATUS(int_status_word));
901907
#else
902908
RETURN_FALSE;
@@ -908,15 +914,14 @@ PHP_FUNCTION(pcntl_wexitstatus)
908914
Returns the number of the signal that terminated the process who's status code is passed */
909915
PHP_FUNCTION(pcntl_wtermsig)
910916
{
911-
#ifdef WTERMSIG
912917
zend_long status_word;
913-
int int_status_word;
914918

915919
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &status_word) == FAILURE) {
916-
return;
920+
return;
917921
}
918922

919-
int_status_word = (int) status_word;
923+
#ifdef WTERMSIG
924+
int int_status_word = (int) status_word;
920925
RETURN_LONG(WTERMSIG(int_status_word));
921926
#else
922927
RETURN_FALSE;
@@ -928,15 +933,14 @@ PHP_FUNCTION(pcntl_wtermsig)
928933
Returns the number of the signal that caused the process to stop who's status code is passed */
929934
PHP_FUNCTION(pcntl_wstopsig)
930935
{
931-
#ifdef WSTOPSIG
932936
zend_long status_word;
933-
int int_status_word;
934937

935938
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &status_word) == FAILURE) {
936-
return;
939+
return;
937940
}
938941

939-
int_status_word = (int) status_word;
942+
#ifdef WSTOPSIG
943+
int int_status_word = (int) status_word;
940944
RETURN_LONG(WSTOPSIG(int_status_word));
941945
#else
942946
RETURN_FALSE;
@@ -1143,6 +1147,10 @@ PHP_FUNCTION(pcntl_signal_get_handler)
11431147
Dispatch signals to signal handlers */
11441148
PHP_FUNCTION(pcntl_signal_dispatch)
11451149
{
1150+
if (zend_parse_parameters_none() == FAILURE) {
1151+
return;
1152+
}
1153+
11461154
pcntl_signal_dispatch();
11471155
RETURN_TRUE;
11481156
}
@@ -1344,7 +1352,7 @@ PHP_FUNCTION(pcntl_getpriority)
13441352
int pri;
13451353

13461354
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|ll", &pid, &who) == FAILURE) {
1347-
RETURN_FALSE;
1355+
return;
13481356
}
13491357

13501358
/* needs to be cleared, since any returned value is valid */
@@ -1417,21 +1425,25 @@ PHP_FUNCTION(pcntl_setpriority)
14171425
Retrieve the error number set by the last pcntl function which failed. */
14181426
PHP_FUNCTION(pcntl_get_last_error)
14191427
{
1420-
RETURN_LONG(PCNTL_G(last_error));
1428+
if (zend_parse_parameters_none() == FAILURE) {
1429+
return;
1430+
}
1431+
1432+
RETURN_LONG(PCNTL_G(last_error));
14211433
}
14221434
/* }}} */
14231435

14241436
/* {{{ proto string pcntl_strerror(int errno)
14251437
Retrieve the system error message associated with the given errno. */
14261438
PHP_FUNCTION(pcntl_strerror)
14271439
{
1428-
zend_long error;
1440+
zend_long error;
14291441

1430-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &error) == FAILURE) {
1431-
RETURN_FALSE;
1432-
}
1442+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &error) == FAILURE) {
1443+
return;
1444+
}
14331445

1434-
RETURN_STRING(strerror(error));
1446+
RETURN_STRING(strerror(error));
14351447
}
14361448
/* }}} */
14371449

@@ -1537,7 +1549,7 @@ void pcntl_signal_dispatch()
15371549
sigprocmask(SIG_SETMASK, &old_mask, NULL);
15381550
}
15391551

1540-
/* {{{ proto bool pcntl_async_signals([bool on[)
1552+
/* {{{ proto bool pcntl_async_signals([bool on])
15411553
Enable/disable asynchronous signal handling and return the old setting. */
15421554
PHP_FUNCTION(pcntl_async_signals)
15431555
{

0 commit comments

Comments
 (0)