static void pcntl_signal_handler(int);
static void pcntl_signal_dispatch();
-
+
void php_register_signal_constants(INIT_FUNC_ARGS)
{
REGISTER_LONG_CONSTANT("SIGTERM", (long) SIGTERM, CONST_CS | CONST_PERSISTENT);
#ifdef SIGSTKFLT
REGISTER_LONG_CONSTANT("SIGSTKFLT",(long) SIGSTKFLT, CONST_CS | CONST_PERSISTENT);
-#endif
+#endif
#ifdef SIGCLD
REGISTER_LONG_CONSTANT("SIGCLD", (long) SIGCLD, CONST_CS | CONST_PERSISTENT);
#endif
}
static PHP_GINIT_FUNCTION(pcntl)
-{
+{
memset(pcntl_globals, 0, sizeof(*pcntl_globals));
}
PCNTL_G(last_error) = errno;
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error %d", errno);
}
-
+
RETURN_LONG((long) id);
}
/* }}} */
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &seconds) == FAILURE)
return;
-
+
RETURN_LONG ((long) alarm(seconds));
}
/* }}} */
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lz|l", &pid, &z_status, &options) == FAILURE)
return;
-
+
convert_to_long_ex(&z_status);
status = Z_LVAL_P(z_status);
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|l", &z_status, &options) == FAILURE)
return;
-
+
convert_to_long_ex(&z_status);
status = Z_LVAL_P(z_status);
}
/* }}} */
-/* {{{ proto bool pcntl_wifexited(int status)
+/* {{{ proto bool pcntl_wifexited(int status)
Returns true if the child status code represents a successful exit */
PHP_FUNCTION(pcntl_wifexited)
{
}
/* }}} */
-/* {{{ proto bool pcntl_wifstopped(int status)
+/* {{{ proto bool pcntl_wifstopped(int status)
Returns true if the child status code represents a stopped process (WUNTRACED must have been used with waitpid) */
PHP_FUNCTION(pcntl_wifstopped)
{
}
/* }}} */
-/* {{{ proto bool pcntl_wifsignaled(int status)
+/* {{{ proto bool pcntl_wifsignaled(int status)
Returns true if the child status code represents a process that was terminated due to a signal */
PHP_FUNCTION(pcntl_wifsignaled)
{
}
/* }}} */
-/* {{{ proto int pcntl_wexitstatus(int status)
+/* {{{ proto int pcntl_wexitstatus(int status)
Returns the status code of a child's exit */
PHP_FUNCTION(pcntl_wexitstatus)
{
}
/* }}} */
-/* {{{ proto int pcntl_wtermsig(int status)
+/* {{{ proto int pcntl_wtermsig(int status)
Returns the number of the signal that terminated the process who's status code is passed */
PHP_FUNCTION(pcntl_wtermsig)
{
}
/* }}} */
-/* {{{ proto int pcntl_wstopsig(int status)
+/* {{{ proto int pcntl_wstopsig(int status)
Returns the number of the signal that caused the process to stop who's status code is passed */
PHP_FUNCTION(pcntl_wstopsig)
{
char *path;
int path_len;
ulong key_num;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|aa", &path, &path_len, &args, &envs) == FAILURE) {
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|aa", &path, &path_len, &args, &envs) == FAILURE) {
return;
}
-
+
if (ZEND_NUM_ARGS() > 1) {
/* Build argument list */
args_hash = HASH_OF(args);
argc = zend_hash_num_elements(args_hash);
-
+
argv = safe_emalloc((argc + 2), sizeof(char *), 0);
*argv = path;
- for ( zend_hash_internal_pointer_reset(args_hash), current_arg = argv+1;
+ for ( zend_hash_internal_pointer_reset(args_hash), current_arg = argv+1;
(argi < argc && (zend_hash_get_current_data(args_hash, (void **) &element) == SUCCESS));
(argi++, current_arg++, zend_hash_move_forward(args_hash)) ) {
/* Build environment pair list */
envs_hash = HASH_OF(envs);
envc = zend_hash_num_elements(envs_hash);
-
+
envp = safe_emalloc((envc + 1), sizeof(char *), 0);
- for ( zend_hash_internal_pointer_reset(envs_hash), pair = envp;
+ for ( zend_hash_internal_pointer_reset(envs_hash), pair = envp;
(envi < envc && (zend_hash_get_current_data(envs_hash, (void **) &element) == SUCCESS));
(envi++, pair++, zend_hash_move_forward(envs_hash)) ) {
switch (return_val = zend_hash_get_current_key_ex(envs_hash, &key, &key_length, &key_num, 0, NULL)) {
convert_to_string_ex(element);
- /* Length of element + equal sign + length of key + null */
+ /* Length of element + equal sign + length of key + null */
pair_length = Z_STRLEN_PP(element) + key_length + 2;
*pair = emalloc(pair_length);
- strlcpy(*pair, key, key_length);
+ strlcpy(*pair, key, key_length);
strlcat(*pair, "=", pair_length);
strlcat(*pair, Z_STRVAL_PP(element), pair_length);
-
+
/* Cleanup */
if (return_val == HASH_KEY_IS_LONG) efree(key);
}
PCNTL_G(last_error) = errno;
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error has occurred: (errno %d) %s", errno, strerror(errno));
}
-
+
/* Cleanup */
for (pair = envp; *pair != NULL; pair++) efree(*pair);
efree(envp);
}
efree(argv);
-
+
RETURN_FALSE;
}
/* }}} */
}
RETURN_TRUE;
}
-
+
if (!zend_is_callable(handle, 0, &func_name TSRMLS_CC)) {
PCNTL_G(last_error) = EINVAL;
php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s is not a callable function name error", func_name);
RETURN_FALSE;
}
efree(func_name);
-
+
/* Add the function name to our signal table */
zend_hash_index_update(&PCNTL_G(php_signal_table), signo, (void **) &handle, sizeof(zval *), (void **) &dest_handle);
if (dest_handle) zval_add_ref(dest_handle);
-
+
if (php_signal4(signo, pcntl_signal_handler, (int) restart_syscalls, 1) == SIG_ERR) {
PCNTL_G(last_error) = errno;
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error assigning signal");
}
/*
- * sigtimedwait and sigwaitinfo can return 0 on success on some
+ * sigtimedwait and sigwaitinfo can return 0 on success on some
* platforms, e.g. NetBSD
*/
if (!signo && siginfo.si_signo) {
EMPTY_SWITCH_DEFAULT_CASE();
}
}
-
+
RETURN_LONG(signo);
}
/* }}} */
long who = PRIO_PROCESS;
long pid = getpid();
int pri;
-
+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|ll", &pid, &who) == FAILURE) {
RETURN_FALSE;
}
- /* needs to be cleared, since any returned value is valid */
+ /* needs to be cleared, since any returned value is valid */
errno = 0;
pri = getpriority(who, pid);
}
RETURN_FALSE;
}
-
+
RETURN_TRUE;
}
/* }}} */
{
struct php_pcntl_pending_signal *psig;
TSRMLS_FETCH();
-
+
psig = PCNTL_G(spares);
if (!psig) {
/* oops, too many signals for us to track, so we'll forget about this one */
sigset_t mask;
sigset_t old_mask;
TSRMLS_FETCH();
-
+
/* Mask all signals */
sigfillset(&mask);
sigprocmask(SIG_BLOCK, &mask, &old_mask);
queue = PCNTL_G(head);
PCNTL_G(head) = NULL; /* simple stores are atomic */
-
+
/* Allocate */
while (queue) {
/* Re-enable queue */
PCNTL_G(processing_signal_queue) = 0;
-
+
/* return signal mask to previous state */
sigprocmask(SIG_SETMASK, &old_mask, NULL);
}
ZEND_ARG_INFO(0, fp)
ZEND_ARG_INFO(0, buffer)
ZEND_END_ARG_INFO()
-
+
ZEND_BEGIN_ARG_INFO(arginfo_stream_set_chunk_size, 0)
ZEND_ARG_INFO(0, fp)
ZEND_ARG_INFO(0, chunk_size)
ZEND_BEGIN_ARG_INFO(arginfo_lcfirst, 0)
ZEND_ARG_INFO(0, str)
ZEND_END_ARG_INFO()
-
+
ZEND_BEGIN_ARG_INFO_EX(arginfo_ucwords, 0, 0, 1)
ZEND_ARG_INFO(0, str)
ZEND_ARG_INFO(0, delimiters)
BG(user_tick_functions) = NULL;
BG(user_filter_map) = NULL;
BG(serialize_lock) = 0;
-
+
memset(&BG(serialize), 0, sizeof(BG(serialize)));
memset(&BG(unserialize), 0, sizeof(BG(unserialize)));
int size;
SetLastError(0);
- /*If the given bugger is not large enough to hold the data, the return value is
- the buffer size, in characters, required to hold the string and its terminating
+ /*If the given bugger is not large enough to hold the data, the return value is
+ the buffer size, in characters, required to hold the string and its terminating
null character. We use this return value to alloc the final buffer. */
size = GetEnvironmentVariableA(str, &dummybuf, 0);
if (GetLastError() == ERROR_ENVVAR_NOT_FOUND) {
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &setting, &setting_len) == FAILURE) {
return;
}
-
+
if(setting_len == 0 || setting[0] == '=') {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid parameter syntax");
RETURN_FALSE;
error_code = SetEnvironmentVariable(pe.key, value);
# if _MSC_VER < 1500
/* Yet another VC6 bug, unset may return env not found */
- if (error_code != 0 ||
+ if (error_code != 0 ||
(error_code == 0 && GetLastError() == ERROR_ENVVAR_NOT_FOUND)) {
# else
if (error_code != 0) { /* success */
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &new_setting) == FAILURE) {
return;
}
-
+
if (new_setting) {
php_error_docref(NULL TSRMLS_CC, E_CORE_ERROR, "magic_quotes_runtime is not supported anymore");
}
instanceof_function(EG(called_scope), fci_cache.calling_scope TSRMLS_CC)) {
fci_cache.called_scope = EG(called_scope);
}
-
+
if (zend_call_function(&fci, &fci_cache TSRMLS_CC) == SUCCESS && fci.retval_ptr_ptr && *fci.retval_ptr_ptr) {
COPY_PZVAL_TO_ZVAL(*return_value, *fci.retval_ptr_ptr);
}
int new_value_len;
char *old_value;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &new_value, &new_value_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p", &new_value, &new_value_len) == FAILURE) {
return;
}
}
-/* empty string behaves like NULL on windows implementation of
+/* empty string behaves like NULL on windows implementation of
getservbyname. Let be portable instead. */
#ifdef PHP_WIN32
if (proto_len == 0) {
/* }}} */
#if ZEND_DEBUG
-/* This function returns an array of ALL valid ini options with values and
+/* This function returns an array of ALL valid ini options with values and
* is not the same as ini_get_all() which returns only registered ini options. Only useful for devs to debug php.ini scanner/parser! */
PHP_FUNCTION(config_get_hash) /* {{{ */
{
dirp = (php_stream *) zend_fetch_resource(&id TSRMLS_CC, -1, "Directory", NULL, 1, php_file_le_stream()); \
if (!dirp) \
RETURN_FALSE; \
- }
-
+ }
+
/* {{{ arginfo */
ZEND_BEGIN_ARG_INFO_EX(arginfo_dir, 0, 0, 0)
ZEND_ARG_INFO(0, dir_handle)
if (id != -1) {
zend_list_addref(id);
}
-
+
DIRG(default_dir) = id;
}
#ifdef GLOB_NOSORT
REGISTER_LONG_CONSTANT("GLOB_NOSORT", GLOB_NOSORT, CONST_CS | CONST_PERSISTENT);
-#else
+#else
# define GLOB_NOSORT 0
#endif
#ifdef GLOB_NOCHECK
REGISTER_LONG_CONSTANT("GLOB_NOCHECK", GLOB_NOCHECK, CONST_CS | CONST_PERSISTENT);
-#else
+#else
# define GLOB_NOCHECK 0
#endif
#ifdef GLOB_NOESCAPE
REGISTER_LONG_CONSTANT("GLOB_NOESCAPE", GLOB_NOESCAPE, CONST_CS | CONST_PERSISTENT);
-#else
+#else
# define GLOB_NOESCAPE 0
#endif
#ifdef GLOB_ERR
REGISTER_LONG_CONSTANT("GLOB_ERR", GLOB_ERR, CONST_CS | CONST_PERSISTENT);
-#else
+#else
# define GLOB_ERR 0
#endif
php_stream_context *context = NULL;
php_stream *dirp;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|r", &dirname, &dir_len, &zcontext) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|r", &dirname, &dir_len, &zcontext) == FAILURE) {
RETURN_NULL();
}
context = php_stream_context_from_zval(zcontext, 0);
-
+
dirp = php_stream_opendir(dirname, REPORT_ERRORS, context);
if (dirp == NULL) {
}
dirp->flags |= PHP_STREAM_FLAG_NO_FCLOSE;
-
+
php_set_default_dir(dirp->rsrc_id TSRMLS_CC);
if (createobject) {
{
char *str;
int ret, str_len;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) == FAILURE) {
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p", &str, &str_len) == FAILURE) {
RETURN_FALSE;
}
-
+
ret = chroot(str);
if (ret != 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s (errno %d)", strerror(errno), errno);
}
php_clear_stat_cache(1, NULL, 0 TSRMLS_CC);
-
+
ret = chdir("/");
-
+
if (ret != 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s (errno %d)", strerror(errno), errno);
RETURN_FALSE;
{
char *str;
int ret, str_len;
-
+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p", &str, &str_len) == FAILURE) {
RETURN_FALSE;
}
RETURN_FALSE;
}
ret = VCWD_CHDIR(str);
-
+
if (ret != 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s (errno %d)", strerror(errno), errno);
RETURN_FALSE;
{
char path[MAXPATHLEN];
char *ret=NULL;
-
+
if (zend_parse_parameters_none() == FAILURE) {
return;
}
{
zval *id = NULL, **tmp, *myself;
php_stream *dirp;
-
+
FETCH_DIRP();
if (!(dirp->flags & PHP_STREAM_FLAG_IS_DIR)) {
RETURN_FALSE;
}
-#ifdef ZTS
+#ifdef ZTS
if (!IS_ABSOLUTE_PATH(pattern, pattern_len)) {
- result = VCWD_GETCWD(cwd, MAXPATHLEN);
+ result = VCWD_GETCWD(cwd, MAXPATHLEN);
if (!result) {
cwd[0] = '\0';
}
snprintf(work_pattern, MAXPATHLEN, "%s%c%s", cwd, DEFAULT_SLASH, pattern);
pattern = work_pattern;
- }
+ }
#endif
-
+
memset(&globbuf, 0, sizeof(glob_t));
globbuf.gl_offs = 0;
if (0 != (ret = glob(pattern, flags & GLOB_FLAGMASK, NULL, &globbuf))) {
/* Some glob implementation simply return no data if no matches
were found, others return the GLOB_NOMATCH error code.
We don't want to treat GLOB_NOMATCH as an error condition
- so that PHP glob() behaves the same on both types of
+ so that PHP glob() behaves the same on both types of
implementations and so that 'foreach (glob() as ...'
can be used for simple glob() calls without further error
checking.
}
/* we need to do this everytime since GLOB_ONLYDIR does not guarantee that
* all directories will be filtered. GNU libc documentation states the
- * following:
- * If the information about the type of the file is easily available
- * non-directories will be rejected but no extra work will be done to
- * determine the information for each file. I.e., the caller must still be
- * able to filter directories out.
+ * following:
+ * If the information about the type of the file is easily available
+ * non-directories will be rejected but no extra work will be done to
+ * determine the information for each file. I.e., the caller must still be
+ * able to filter directories out.
*/
if (flags & GLOB_ONLYDIR) {
struct stat s;
}
}
/* }}} */
-#endif
+#endif
/* {{{ proto array scandir(string dir [, int sorting_order [, resource context]])
List files & directories inside the specified path */
php_error_docref(NULL TSRMLS_CC, E_WARNING, "(errno %d): %s", errno, strerror(errno));
RETURN_FALSE;
}
-
+
array_init(return_value);
for (i = 0; i < n; i++) {
char *p;
int fd;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ps", &dir, &dir_len, &prefix, &prefix_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "pp", &dir, &dir_len, &prefix, &prefix_len) == FAILURE) {
return;
}
if (p_len > 64) {
p[63] = '\0';
}
-
+
RETVAL_FALSE;
if ((fd = php_open_temporary_fd_ex(dir, p, &opened_path, 1 TSRMLS_CC)) >= 0) {
zval *zcontext = NULL;
php_stream_context *context;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|r", &dir, &dir_len, &zcontext) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|r", &dir, &dir_len, &zcontext) == FAILURE) {
RETURN_FALSE;
}
{
long arg1 = 0;
int oldumask;
-
+
oldumask = umask(077);
if (BG(umask) == -1) {
BG(umask) = oldumask;
}
-
+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &arg1) == FAILURE) {
RETURN_FALSE;
}