Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix crash in recovery that occurs during backup.
Change-Id: I8d13646eede75c64878b50a8b6f4617a48e10b32
- Loading branch information
Showing
1 changed file
with
11 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,13 +50,16 @@ static struct pid { | |
pid_t pid; | ||
} *pidlist; | ||
|
||
extern char **environ; | ||
|
||
FILE * | ||
__popen(const char *program, const char *type) | ||
{ | ||
struct pid * volatile cur; | ||
FILE *iop; | ||
int pdes[2]; | ||
pid_t pid; | ||
char *argp[] = {"sh", "-c", NULL, NULL}; | ||
|
||
if ((*type != 'r' && *type != 'w') || type[1] != '\0') { | ||
errno = EINVAL; | ||
|
@@ -71,7 +74,7 @@ __popen(const char *program, const char *type) | |
return (NULL); | ||
} | ||
|
||
switch (pid = vfork()) { | ||
switch (pid = fork()) { | ||
case -1: /* Error. */ | ||
(void)close(pdes[0]); | ||
(void)close(pdes[1]); | ||
|
@@ -82,24 +85,17 @@ __popen(const char *program, const char *type) | |
{ | ||
struct pid *pcur; | ||
/* | ||
* because vfork() instead of fork(), must leak FILE *, | ||
* but luckily we are terminally headed for an execl() | ||
* We fork()'d, we got our own copy of the list, no | ||
* contention. | ||
*/ | ||
for (pcur = pidlist; pcur; pcur = pcur->next) | ||
close(fileno(pcur->fp)); | ||
|
||
if (*type == 'r') { | ||
int tpdes1 = pdes[1]; | ||
|
||
(void) close(pdes[0]); | ||
/* | ||
* We must NOT modify pdes, due to the | ||
* semantics of vfork. | ||
*/ | ||
if (tpdes1 != STDOUT_FILENO) { | ||
(void)dup2(tpdes1, STDOUT_FILENO); | ||
(void)close(tpdes1); | ||
tpdes1 = STDOUT_FILENO; | ||
if (pdes[1] != STDOUT_FILENO) { | ||
(void)dup2(pdes[1], STDOUT_FILENO); | ||
(void)close(pdes[1]); | ||
} | ||
} else { | ||
(void)close(pdes[1]); | ||
|
@@ -108,7 +104,8 @@ __popen(const char *program, const char *type) | |
(void)close(pdes[0]); | ||
} | ||
} | ||
execl(_PATH_BSHELL, "sh", "-c", program, (char *)NULL); | ||
argp[2] = (char *)program; | ||
execve(_PATH_BSHELL, argp, environ); | ||
_exit(127); | ||
/* NOTREACHED */ | ||
} | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
SWQJueLian
|
||
|
2 comments
on commit 0c27228
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this fix the crash I reported on your G+ Community the other day (Ryan Gay)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ryangay can you link the issue? It may.
HI, I was a kid,come from china, I have a question, and I hope to get your reply,how to prevent the automatic shutdown(restart) of the recovery,About 2 min,the recovery will be shutdown or restart. my english is not good.so i hope you not mind. oh,restore is bug, tips is MD5 not true.hope your fix