[MIPS] Cleaned up sig_0 error messages and added a few more checks.
Change-Id: I316e60d891af99c18fc4b838b35a6d8977d0e7c8 Signed-off-by: Pete Delaney <piet.delaney@imgtec.com>
This commit is contained in:
@@ -63,6 +63,7 @@ __hidden char *map_portable_signum_to_name(int portable_signum)
|
||||
char *name;
|
||||
|
||||
switch(portable_signum) {
|
||||
case 0: name = "SIG_0_PORTABLE:0"; break;
|
||||
case SIGHUP_PORTABLE: name = "SIGHUP_PORTABLE:1"; break;
|
||||
case SIGINT_PORTABLE: name = "SIGINT_PORTABLE:2"; break;
|
||||
case SIGQUIT_PORTABLE: name = "SIGQUIT_PORTABLE:3"; break;
|
||||
@@ -140,6 +141,7 @@ __hidden char *map_mips_signum_to_name(int mips_signum)
|
||||
char *name;
|
||||
|
||||
switch(mips_signum) {
|
||||
case 0: name = "SIG_0:0"; break;
|
||||
case SIGHUP: name = "SIGHUP:1"; break;
|
||||
case SIGINT: name = "SIGINT:2"; break;
|
||||
case SIGQUIT: name = "SIGQUIT:3"; break;
|
||||
@@ -223,6 +225,10 @@ __hidden int signum_pton(int portable_signum)
|
||||
int mips_signum = -1;
|
||||
|
||||
switch(portable_signum) {
|
||||
|
||||
case 0: /* 0 */
|
||||
return 0;
|
||||
|
||||
case SIGHUP_PORTABLE: /* 1 */
|
||||
return SIGHUP;
|
||||
|
||||
@@ -340,8 +346,8 @@ __hidden int signum_pton(int portable_signum)
|
||||
} else if (portable_signum > NSIG_PORTABLE) {
|
||||
mips_signum = (portable_signum - NSIG_PORTABLE) + NSIG;
|
||||
} else {
|
||||
ALOGE("%s: 0 <= portable_signum:%d <= NSIG_PORTABLE:%d; Not supported, return(0);",
|
||||
__func__, portable_signum, NSIG_PORTABLE);
|
||||
ALOGE("%s: 0 < portable_signum:%d <= NSIG_PORTABLE:%d; Not supported, return(0);",
|
||||
__func__, portable_signum, NSIG_PORTABLE);
|
||||
|
||||
mips_signum = 0;
|
||||
}
|
||||
@@ -362,6 +368,9 @@ __hidden int signum_ntop(int mips_signum)
|
||||
int portable_ssignum = -1;
|
||||
|
||||
switch(mips_signum) {
|
||||
case 0: /* 0 */
|
||||
return 0;
|
||||
|
||||
case SIGHUP: /* 1 */
|
||||
return SIGHUP_PORTABLE;
|
||||
|
||||
@@ -696,9 +705,10 @@ do_signal_portable(int portable_signum, sighandler_portable_t portable_handler,
|
||||
|
||||
mips_signum = signum_pton(portable_signum);
|
||||
|
||||
if ((portable_signum != 0) && ((mips_signum <= 0) || (mips_signum > NSIG))) {
|
||||
if ((mips_signum <= 0) || (mips_signum > NSIG)) {
|
||||
/*
|
||||
* Invalid request; Let the kernel generate the proper return value and set errno.
|
||||
* Invalid signal number, perhaps zero. Let the kernel generate the
|
||||
* proper return value and set errno.
|
||||
*/
|
||||
mips_handler = sighandler_pton(portable_handler, 0);
|
||||
rv = mips_signal_fn(mips_signum, mips_handler);
|
||||
@@ -801,6 +811,11 @@ static int do_kill(int id, int portable_signum, int (*fn)(int, int))
|
||||
|
||||
mips_signum = signum_pton(portable_signum);
|
||||
|
||||
/*
|
||||
* SIG_0 gets passed down to the kernel to test for the existence of a process.
|
||||
* If a non-zero portable_signum has been mapped to 0,
|
||||
* it's unsupported and will be ignored.
|
||||
*/
|
||||
if ((portable_signum != 0) && (mips_signum == 0)) {
|
||||
rv = 0;
|
||||
} else {
|
||||
@@ -876,6 +891,10 @@ int WRAP(tgkill)(int tgid, int tid, int portable_signum)
|
||||
|
||||
mips_signum = signum_pton(portable_signum);
|
||||
|
||||
/*
|
||||
* If a non-zero portable_signum has been mapped to 0,
|
||||
* it is unsupported and will be ignored.
|
||||
*/
|
||||
if ((portable_signum != 0) && (mips_signum == 0))
|
||||
rv = 0;
|
||||
else
|
||||
@@ -895,6 +914,11 @@ int WRAP(raise)(int portable_signum)
|
||||
|
||||
ALOGV("%s(portable_signum:%d:'%s') {", __func__, portable_signum, portable_signame);
|
||||
|
||||
/*
|
||||
* SIG_0 gets passed down to the kernel to test for the existence of a process.
|
||||
* If a non-zero portable_signum has been mapped to 0,
|
||||
* it's unsupported and will be ignored.
|
||||
*/
|
||||
if ((portable_signum != 0) && (mips_signum == 0))
|
||||
rv = 0;
|
||||
else
|
||||
@@ -1098,8 +1122,11 @@ static int do_sigaction_portable(int portable_signum, const struct sigaction_por
|
||||
mips_signum = signum_pton(portable_signum);
|
||||
mips_signame = map_mips_signum_to_name(mips_signum);
|
||||
|
||||
/*
|
||||
* If a non-zero portable_signum has been mapped to 0,
|
||||
* it's unsupported and will be ignored.
|
||||
*/
|
||||
if ((portable_signum != 0) && (mips_signum == 0)) {
|
||||
/* We got a portable signum that we can't map; Ignore the request */
|
||||
rv = 0;
|
||||
goto done;
|
||||
}
|
||||
@@ -1407,9 +1434,11 @@ int WRAP(siginterrupt)(int portable_signum, int flag)
|
||||
|
||||
mips_signum = signum_pton(portable_signum);
|
||||
|
||||
/*
|
||||
* If a non-zero portable_signum has been mapped to 0,
|
||||
* it's unsupported and will be ignored.
|
||||
*/
|
||||
if ((portable_signum != 0) && (mips_signum == 0)) {
|
||||
ALOGE("%s: Unsupported portable_signum:%d; Ignoring.", __func__,
|
||||
portable_signum);
|
||||
rv = 0;
|
||||
} else {
|
||||
rv = REAL(siginterrupt)(mips_signum, flag);
|
||||
@@ -1663,6 +1692,15 @@ int WRAP(rt_sigqueueinfo)(pid_t pid, int portable_sig, siginfo_portable_t *porta
|
||||
|
||||
native_sig = signum_pton(portable_sig);
|
||||
|
||||
/*
|
||||
* If a non-zero portable_signum has been mapped to 0,
|
||||
* it's unsupported and will be ignored.
|
||||
*/
|
||||
if ((portable_sig != 0) && (native_sig == 0)) {
|
||||
rv = 0;
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (portable_sip != NULL) {
|
||||
native_sip = &native_siginfo;
|
||||
siginfo_pton(portable_sip, native_sip);
|
||||
@@ -1671,6 +1709,7 @@ int WRAP(rt_sigqueueinfo)(pid_t pid, int portable_sig, siginfo_portable_t *porta
|
||||
}
|
||||
rv = syscall(__NR_rt_sigqueueinfo, pid, native_sig, native_sip);
|
||||
|
||||
done:
|
||||
ALOGV("%s: return(rv:%d); }", __func__, rv);
|
||||
return rv;
|
||||
}
|
||||
@@ -1694,6 +1733,14 @@ int WRAP(rt_tgsigqueueinfo)(pid_t tgid, pid_t pid, int portable_sig,
|
||||
|
||||
native_sig = signum_pton(portable_sig);
|
||||
|
||||
/*
|
||||
* If a non-zero portable_signum has been mapped to 0,
|
||||
* it's unsupported and will be ignored.
|
||||
*/
|
||||
if ((portable_sig != 0) && (native_sig == 0)) {
|
||||
rv = 0;
|
||||
goto done;
|
||||
}
|
||||
if (portable_sip != NULL) {
|
||||
native_sip = &native_siginfo;
|
||||
siginfo_pton(portable_sip, native_sip);
|
||||
@@ -1702,6 +1749,7 @@ int WRAP(rt_tgsigqueueinfo)(pid_t tgid, pid_t pid, int portable_sig,
|
||||
}
|
||||
rv = syscall(__NR_rt_tgsigqueueinfo, pid, native_sig, native_sip);
|
||||
|
||||
done:
|
||||
ALOGV("%s: return(rv:%d); }", __func__, rv);
|
||||
return rv;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user