mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-05 12:16:00 +00:00
app_dahdiras: Use waitpid instead of wait4.
Several places in the code were using wait4 while other places were using waitpid. This change makes all places use waitpid in order to make things more consistent and since the 'rusage' object passed in/out of wait4 was never used. (closes issue ASTERISK-22557) Reported by: YvesGael Patches: asterisk-11.5.1-wait4.patch uploaded by hurdman (license 6537) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@402546 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -150,7 +150,7 @@ static void run_ras(struct ast_channel *chan, char *args)
|
|||||||
ast_log(LOG_WARNING, "Failed to spawn RAS\n");
|
ast_log(LOG_WARNING, "Failed to spawn RAS\n");
|
||||||
} else {
|
} else {
|
||||||
for (;;) {
|
for (;;) {
|
||||||
res = wait4(pid, &status, WNOHANG, NULL);
|
res = waitpid(pid, &status, WNOHANG);
|
||||||
if (!res) {
|
if (!res) {
|
||||||
/* Check for hangup */
|
/* Check for hangup */
|
||||||
if (ast_check_hangup(chan) && !signalled) {
|
if (ast_check_hangup(chan) && !signalled) {
|
||||||
@@ -163,7 +163,7 @@ static void run_ras(struct ast_channel *chan, char *args)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (res < 0) {
|
if (res < 0) {
|
||||||
ast_log(LOG_WARNING, "wait4 returned %d: %s\n", res, strerror(errno));
|
ast_log(LOG_WARNING, "waitpid returned %d: %s\n", res, strerror(errno));
|
||||||
}
|
}
|
||||||
if (WIFEXITED(status)) {
|
if (WIFEXITED(status)) {
|
||||||
ast_verb(3, "RAS on %s terminated with status %d\n", ast_channel_name(chan), WEXITSTATUS(status));
|
ast_verb(3, "RAS on %s terminated with status %d\n", ast_channel_name(chan), WEXITSTATUS(status));
|
||||||
|
@@ -1233,7 +1233,6 @@ int ast_safe_system(const char *s)
|
|||||||
{
|
{
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
int res;
|
int res;
|
||||||
struct rusage rusage;
|
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
#if defined(HAVE_WORKING_FORK) || defined(HAVE_WORKING_VFORK)
|
#if defined(HAVE_WORKING_FORK) || defined(HAVE_WORKING_VFORK)
|
||||||
@@ -1265,7 +1264,7 @@ int ast_safe_system(const char *s)
|
|||||||
_exit(1);
|
_exit(1);
|
||||||
} else if (pid > 0) {
|
} else if (pid > 0) {
|
||||||
for (;;) {
|
for (;;) {
|
||||||
res = wait4(pid, &status, 0, &rusage);
|
res = waitpid(pid, &status, 0);
|
||||||
if (res > -1) {
|
if (res > -1) {
|
||||||
res = WIFEXITED(status) ? WEXITSTATUS(status) : -1;
|
res = WIFEXITED(status) ? WEXITSTATUS(status) : -1;
|
||||||
break;
|
break;
|
||||||
@@ -1751,7 +1750,7 @@ static void _child_handler(int sig)
|
|||||||
/*
|
/*
|
||||||
* Reap all dead children -- not just one
|
* Reap all dead children -- not just one
|
||||||
*/
|
*/
|
||||||
for (n = 0; wait4(-1, &status, WNOHANG, NULL) > 0; n++)
|
for (n = 0; waitpid(-1, &status, WNOHANG) > 0; n++)
|
||||||
;
|
;
|
||||||
if (n == 0 && option_debug)
|
if (n == 0 && option_debug)
|
||||||
printf("Huh? Child handler, but nobody there?\n");
|
printf("Huh? Child handler, but nobody there?\n");
|
||||||
|
@@ -1330,7 +1330,6 @@ int ast_safe_system(const char *s)
|
|||||||
int x;
|
int x;
|
||||||
#endif
|
#endif
|
||||||
int res;
|
int res;
|
||||||
struct rusage rusage;
|
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
#if defined(HAVE_WORKING_FORK) || defined(HAVE_WORKING_VFORK)
|
#if defined(HAVE_WORKING_FORK) || defined(HAVE_WORKING_VFORK)
|
||||||
@@ -1352,7 +1351,7 @@ int ast_safe_system(const char *s)
|
|||||||
_exit(1);
|
_exit(1);
|
||||||
} else if (pid > 0) {
|
} else if (pid > 0) {
|
||||||
for(;;) {
|
for(;;) {
|
||||||
res = wait4(pid, &status, 0, &rusage);
|
res = waitpid(pid, &status, 0);
|
||||||
if (res > -1) {
|
if (res > -1) {
|
||||||
res = WIFEXITED(status) ? WEXITSTATUS(status) : -1;
|
res = WIFEXITED(status) ? WEXITSTATUS(status) : -1;
|
||||||
break;
|
break;
|
||||||
|
Reference in New Issue
Block a user