openrc: avoid unnecessary malloc inside sig-handler
malloc (called by xasprintf) is not async-signal-safe. beside, the string here is constant, so there's no need to malloc it all. eerrorx isn't async-signal-safe either (due to calling fprintf and exit) but consequence of them are _typically_ not as grave as calling malloc while it's internal state is inconsistent. Bug: https://github.com/OpenRC/openrc/issues/589
This commit is contained in:
parent
a28bdc7e5c
commit
459783bbad
@ -382,7 +382,7 @@ static void
|
|||||||
handle_signal(int sig)
|
handle_signal(int sig)
|
||||||
{
|
{
|
||||||
int serrno = errno;
|
int serrno = errno;
|
||||||
char *signame = NULL;
|
const char *signame = NULL;
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
RC_PID *pi;
|
RC_PID *pi;
|
||||||
int status = 0;
|
int status = 0;
|
||||||
@ -414,15 +414,15 @@ handle_signal(int sig)
|
|||||||
|
|
||||||
case SIGINT:
|
case SIGINT:
|
||||||
if (!signame)
|
if (!signame)
|
||||||
xasprintf(&signame, "SIGINT");
|
signame = "SIGINT";
|
||||||
/* FALLTHROUGH */
|
/* FALLTHROUGH */
|
||||||
case SIGTERM:
|
case SIGTERM:
|
||||||
if (!signame)
|
if (!signame)
|
||||||
xasprintf(&signame, "SIGTERM");
|
signame = "SIGTERM";
|
||||||
/* FALLTHROUGH */
|
/* FALLTHROUGH */
|
||||||
case SIGQUIT:
|
case SIGQUIT:
|
||||||
if (!signame)
|
if (!signame)
|
||||||
xasprintf(&signame, "SIGQUIT");
|
signame = "SIGQUIT";
|
||||||
eerrorx("%s: caught %s, aborting", applet, signame);
|
eerrorx("%s: caught %s, aborting", applet, signame);
|
||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
case SIGUSR1:
|
case SIGUSR1:
|
||||||
|
Loading…
Reference in New Issue
Block a user