signal: correct signal() return value & errno
Signed-off-by: ligd <liguiding1@xiaomi.com>
This commit is contained in:
parent
eef619fc46
commit
092c78d636
@ -26,6 +26,7 @@
|
||||
|
||||
#include <signal.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
@ -59,9 +60,14 @@ _sa_handler_t signal(int signo, _sa_handler_t func)
|
||||
{
|
||||
struct sigaction act;
|
||||
struct sigaction oact;
|
||||
int ret;
|
||||
int ret = -EINVAL;
|
||||
|
||||
DEBUGASSERT(GOOD_SIGNO(signo) && func != SIG_ERR && func != SIG_HOLD);
|
||||
if (!GOOD_SIGNO(signo))
|
||||
{
|
||||
goto err;
|
||||
}
|
||||
|
||||
DEBUGASSERT(func != SIG_ERR && func != SIG_HOLD);
|
||||
|
||||
/* Initialize the sigaction structure */
|
||||
|
||||
@ -86,7 +92,7 @@ _sa_handler_t signal(int signo, _sa_handler_t func)
|
||||
{
|
||||
/* Would happen if signo were invalid */
|
||||
|
||||
return (_sa_handler_t)SIG_ERR;
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
|
||||
@ -104,5 +110,7 @@ _sa_handler_t signal(int signo, _sa_handler_t func)
|
||||
return oact.sa_handler;
|
||||
}
|
||||
|
||||
err:
|
||||
set_errno(-ret);
|
||||
return (_sa_handler_t)SIG_ERR;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user