summaryrefslogtreecommitdiff
path: root/threadproc
diff options
context:
space:
mode:
authorsf <sf@13f79535-47bb-0310-9956-ffa450edef68>2011-10-15 21:26:14 +0000
committersf <sf@13f79535-47bb-0310-9956-ffa450edef68>2011-10-15 21:26:14 +0000
commit5eb5d3cbbe46477b30ef313ecb9dda26e952667f (patch)
tree8aa56e5b65132f2554aff083dcd035034a716bc1 /threadproc
parentfca81c8e8ee63ac7f2021827ca40e1b1fbbe91cb (diff)
downloadlibapr-5eb5d3cbbe46477b30ef313ecb9dda26e952667f.tar.gz
backport r979891:
Fix various issues found by cppcheck - error handling issues - use of uninitialized data - null pointer dereference - unused variables - memory/fd leaks - broken code in threadproc/beos/proc.c git-svn-id: http://svn.apache.org/repos/asf/apr/apr/branches/1.5.x@1183724 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'threadproc')
-rw-r--r--threadproc/beos/proc.c7
-rw-r--r--threadproc/unix/proc.c7
-rw-r--r--threadproc/unix/procsup.c4
3 files changed, 9 insertions, 9 deletions
diff --git a/threadproc/beos/proc.c b/threadproc/beos/proc.c
index ee8afb8d1..97c05a70a 100644
--- a/threadproc/beos/proc.c
+++ b/threadproc/beos/proc.c
@@ -362,8 +362,9 @@ APR_DECLARE(apr_status_t) apr_procattr_child_in_set(apr_procattr_t *attr, apr_fi
== APR_SUCCESS)
rv = apr_file_inherit_set(attr->child_in);
}
+ }
- if (parent_in != NULL && rv == APR_SUCCESS) {
+ if (parent_in != NULL && rv == APR_SUCCESS)
rv = apr_file_dup(&attr->parent_in, parent_in, attr->pool);
return rv;
@@ -391,7 +392,7 @@ APR_DECLARE(apr_status_t) apr_procattr_child_out_set(apr_procattr_t *attr, apr_f
}
}
- if (parent_out != NULL && rv == APR_SUCCESS) {
+ if (parent_out != NULL && rv == APR_SUCCESS)
rv = apr_file_dup(&attr->parent_out, parent_out, attr->pool);
return rv;
@@ -419,7 +420,7 @@ APR_DECLARE(apr_status_t) apr_procattr_child_err_set(apr_procattr_t *attr, apr_f
}
}
- if (parent_err != NULL && rv == APR_SUCCESS) {
+ if (parent_err != NULL && rv == APR_SUCCESS)
rv = apr_file_dup(&attr->parent_err, parent_err, attr->pool);
return rv;
diff --git a/threadproc/unix/proc.c b/threadproc/unix/proc.c
index e5a3df9b4..69d3690ce 100644
--- a/threadproc/unix/proc.c
+++ b/threadproc/unix/proc.c
@@ -396,7 +396,6 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new,
return errno;
}
else if (new->pid == 0) {
- int status;
/* child process */
/*
@@ -469,7 +468,7 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new,
/* Only try to switch if we are running as root */
if (attr->gid != -1 && !geteuid()) {
- if ((status = setgid(attr->gid))) {
+ if (setgid(attr->gid)) {
if (attr->errfn) {
attr->errfn(pool, errno, "setting of group failed");
}
@@ -478,7 +477,7 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new,
}
if (attr->uid != -1 && !geteuid()) {
- if ((status = setuid(attr->uid))) {
+ if (setuid(attr->uid)) {
if (attr->errfn) {
attr->errfn(pool, errno, "setting of user failed");
}
@@ -486,7 +485,7 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new,
}
}
- if ((status = limit_proc(attr)) != APR_SUCCESS) {
+ if (limit_proc(attr) != APR_SUCCESS) {
if (attr->errfn) {
attr->errfn(pool, errno, "setting of resource limits failed");
}
diff --git a/threadproc/unix/procsup.c b/threadproc/unix/procsup.c
index 376baf21f..94177f92a 100644
--- a/threadproc/unix/procsup.c
+++ b/threadproc/unix/procsup.c
@@ -18,8 +18,6 @@
APR_DECLARE(apr_status_t) apr_proc_detach(int daemonize)
{
- int x;
-
if (chdir("/") == -1) {
return errno;
}
@@ -28,6 +26,8 @@ APR_DECLARE(apr_status_t) apr_proc_detach(int daemonize)
/* Don't detach for MPE because child processes can't survive the death of
* the parent. */
if (daemonize) {
+ int x;
+
if ((x = fork()) > 0) {
exit(0);
}