summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorHanhui <sylixos@gmail.com>2019-04-18 14:59:09 (GMT)
committer Hanhui <sylixos@gmail.com>2019-03-07 12:37:37 (GMT)
commit92baf5d4e755f48b70a9223c932e9cb383fc2b6f (patch)
tree0155a1bb86fe6f022bb46f73e3f4e1a2df57baa8
parentf25fa7a9e86de2baee679a20f795001c46248b58 (diff)
downloadAIC-OS-92baf5d4e755f48b70a9223c932e9cb383fc2b6f.zip
Fixed SCHED_FIFO error and SIGKILL to process do not handle user action.
-rw-r--r--SylixOS/debug/gdb/gdbserver.c4
-rw-r--r--SylixOS/fs/mtd/nand/nand_base.c10
-rw-r--r--SylixOS/include/network/lwip/netif.h3
-rw-r--r--SylixOS/kernel/core/_CandTable.c11
-rw-r--r--SylixOS/kernel/include/k_kernel.h2
-rw-r--r--SylixOS/kernel/interface/ThreadDelete.c4
-rw-r--r--SylixOS/kernel/show/ThreadShow.c2
-rw-r--r--SylixOS/loader/include/loader_vppatch.h5
-rw-r--r--SylixOS/loader/src/loader_vppatch.c119
-rw-r--r--SylixOS/loader/src/loader_vpthread.c12
-rw-r--r--SylixOS/net/lwip/bonding/netbonding.c18
-rw-r--r--SylixOS/net/lwip/bridge/netbridge.c20
-rw-r--r--SylixOS/net/lwip/netdev/netdev.c9
-rw-r--r--SylixOS/net/lwip/src/core/netif.c1
-rw-r--r--SylixOS/posix/pthread/pthread_key.c18
-rw-r--r--SylixOS/shell/ttinyShell/ttinyShellLib.c16
-rw-r--r--SylixOS/shell/ttinyShell/ttinyShellSysCmd.c4
-rw-r--r--SylixOS/system/signal/signal.c22
-rw-r--r--SylixOS/system/signal/signalEvent.c12
-rw-r--r--SylixOS/system/signal/signalLib.c227
20 files changed, 367 insertions, 152 deletions
diff --git a/SylixOS/debug/gdb/gdbserver.c b/SylixOS/debug/gdb/gdbserver.c
index 17d0e59..f77fb34 100644
--- a/SylixOS/debug/gdb/gdbserver.c
+++ b/SylixOS/debug/gdb/gdbserver.c
@@ -2456,8 +2456,8 @@ static VOID gdbExit (INT iSigNo)
}
if (!pparam->GDB_bAttached && !pparam->GDB_bExited) { /* 如果不是attch则停止进程 */
- kill(pparam->GDB_iPid, SIGABRT); /* 强制进程停止 */
- LW_GDB_MSG("[GDB]Warning: Process is killed (SIGABRT) by GDB server.\n"
+ kill(pparam->GDB_iPid, SIGKILL); /* 强制进程停止 */
+ LW_GDB_MSG("[GDB]Warning: Process is killed (SIGKILL) by GDB server.\n"
" Restart SylixOS is recommended!\n");
}
#if LW_CFG_SMP_EN > 0
diff --git a/SylixOS/fs/mtd/nand/nand_base.c b/SylixOS/fs/mtd/nand/nand_base.c
index 46c474f..4ae30a7 100644
--- a/SylixOS/fs/mtd/nand/nand_base.c
+++ b/SylixOS/fs/mtd/nand/nand_base.c
@@ -85,6 +85,7 @@ static struct nand_ecclayout nand_oob_8 = {
.length = 2} }
};
+#ifdef NO_YAFFS_512_COMPAT
static struct nand_ecclayout nand_oob_16 = {
.eccbytes = 6,
.eccpos = {0, 1, 2, 3, 6, 7},
@@ -92,6 +93,15 @@ static struct nand_ecclayout nand_oob_16 = {
{.offset = 8,
. length = 8} }
};
+#else /* Zhang.ZG */
+static struct nand_ecclayout nand_oob_16 = {
+ .eccbytes = 6,
+ .eccpos = {8, 9, 10, 13, 14, 15},
+ .oobfree = {
+ {.offset = 0,
+ .length = 16} }
+};
+#endif
static struct nand_ecclayout nand_oob_64 = {
.eccbytes = 24,
diff --git a/SylixOS/include/network/lwip/netif.h b/SylixOS/include/network/lwip/netif.h
index 025da9d..77c9506 100644
--- a/SylixOS/include/network/lwip/netif.h
+++ b/SylixOS/include/network/lwip/netif.h
@@ -414,7 +414,8 @@ struct netif {
#define NETIF_FLAG2_PROMISC 2
#define NETIF_FLAG2_ALLMULTI 4
int priv_flags;
- void *ext_eth; /* net bridge or bonding ctl */
+ void *ext_eth; /* net bridge or bonding or ... eth node */
+ void *ext_ctl; /* net bridge or bonding or ... ctl block */
void *flowctl; /* net flow ctl */
u16_t vlanid; /* include tag & pri */
int metric; /* netif metric (NOT support now) */
diff --git a/SylixOS/kernel/core/_CandTable.c b/SylixOS/kernel/core/_CandTable.c
index 812cd5e..b0d048c 100644
--- a/SylixOS/kernel/core/_CandTable.c
+++ b/SylixOS/kernel/core/_CandTable.c
@@ -95,18 +95,13 @@ static PLW_CLASS_TCB _CandTableNext (PLW_CLASS_PCBBMAP ppcbbmap, UINT8 ucPrio
ppcb = &ppcbbmap->PCBM_pcb[ucPriority];
ptcb = _LIST_ENTRY(ppcb->PCB_pringReadyHeader,
- LW_CLASS_TCB,
- TCB_ringReady); /* 从就绪环中取出一个线程 */
+ LW_CLASS_TCB, TCB_ringReady); /* 从就绪环中取出一个线程 */
- if (ptcb->TCB_ucSchedPolicy == LW_OPTION_SCHED_FIFO) { /* 如果是 FIFO 直接运行 */
- return (ptcb);
-
- } else if (ptcb->TCB_usSchedCounter == 0) { /* 缺少时间片 */
+ if (ptcb->TCB_usSchedCounter == 0) { /* 缺少时间片 */
ptcb->TCB_usSchedCounter = ptcb->TCB_usSchedSlice; /* 补充时间片 */
_list_ring_next(&ppcb->PCB_pringReadyHeader); /* 下一个 */
ptcb = _LIST_ENTRY(ppcb->PCB_pringReadyHeader,
- LW_CLASS_TCB,
- TCB_ringReady);
+ LW_CLASS_TCB, TCB_ringReady);
}
return (ptcb);
diff --git a/SylixOS/kernel/include/k_kernel.h b/SylixOS/kernel/include/k_kernel.h
index d4432c3..29b4bfe 100644
--- a/SylixOS/kernel/include/k_kernel.h
+++ b/SylixOS/kernel/include/k_kernel.h
@@ -51,7 +51,7 @@
#define __SYLIXOS_MAJOR_VER 1
#define __SYLIXOS_MINOR_VER 9
#define __SYLIXOS_PATCH_VER 9
-#define __SYLIXOS_PATCH_PAD 8
+#define __SYLIXOS_PATCH_PAD 9
/*********************************************************************************************************
版本格式
diff --git a/SylixOS/kernel/interface/ThreadDelete.c b/SylixOS/kernel/interface/ThreadDelete.c
index a28ab56..fbd7d9d 100644
--- a/SylixOS/kernel/interface/ThreadDelete.c
+++ b/SylixOS/kernel/interface/ThreadDelete.c
@@ -434,7 +434,7 @@ void exit (int iCode)
if (pvprocCur) {
if (pvprocCur->VP_ulMainThread == ulId) {
- vprocExit(__LW_VP_GET_CUR_PROC(), ulId, iCode); /* 进程结束 */
+ vprocExit(pvprocCur, ulId, iCode); /* 进程结束 */
}
#if LW_CFG_SIGNAL_EN > 0
else {
@@ -475,7 +475,7 @@ void _exit (int iCode)
if (pvprocCur) {
pvprocCur->VP_bRunAtExit = LW_FALSE; /* 不执行 atexit 安装函数 */
if (pvprocCur->VP_ulMainThread == ulId) {
- vprocExit(__LW_VP_GET_CUR_PROC(), ulId, iCode); /* 进程结束 */
+ vprocExit(pvprocCur, ulId, iCode); /* 进程结束 */
}
#if LW_CFG_SIGNAL_EN > 0
else {
diff --git a/SylixOS/kernel/show/ThreadShow.c b/SylixOS/kernel/show/ThreadShow.c
index e79c3e3..7994676 100644
--- a/SylixOS/kernel/show/ThreadShow.c
+++ b/SylixOS/kernel/show/ThreadShow.c
@@ -116,7 +116,7 @@ VOID API_ThreadShowEx (pid_t pid)
}
#if LW_CFG_CPU_WORD_LENGHT == 64
- if (tcbdesc.TCBD_ulWakeupLeft > 9999999999l) {
+ if (tcbdesc.TCBD_ulWakeupLeft > 999999999l) {
lib_strcpy(cWakeupLeft, "--");
} else
#endif
diff --git a/SylixOS/loader/include/loader_vppatch.h b/SylixOS/loader/include/loader_vppatch.h
index 8c47c9c..8af3e69 100644
--- a/SylixOS/loader/include/loader_vppatch.h
+++ b/SylixOS/loader/include/loader_vppatch.h
@@ -101,6 +101,7 @@ typedef struct lw_ld_vproc {
LW_FD_DESC VP_fddescTbl[LW_VP_MAX_FILES]; /* 进程 fd 表 */
+ BOOL VP_bKillPrepare; /* 清除进程前是否需要 release */
INT VP_iExitMode; /* 退出模式 */
LW_LD_VPROC_T VP_vptimer[3]; /* REAL / VIRTUAL / PROF 定时器*/
INT64 VP_i64Tick; /* itimer tick 辅助变量 */
@@ -164,7 +165,9 @@ pid_t vprocGetPidByTcb(PLW_CLASS_TCB ptcb);
pid_t vprocGetPidByTcbNoLock(PLW_CLASS_TCB ptcb);
pid_t vprocGetPidByTcbdesc(PLW_CLASS_TCB_DESC ptcbdesc);
pid_t vprocGetPidByThread(LW_OBJECT_HANDLE ulId);
+VOID vprocKillPrepare(pid_t pid, LW_OBJECT_HANDLE ulId);
LW_OBJECT_HANDLE vprocMainThread(pid_t pid);
+BOOL vprocIsMainThread(VOID);
INT vprocNotifyParent(LW_LD_VPROC *pvproc, INT iSigCode, BOOL bUpDateStat);
VOID vprocReclaim(LW_LD_VPROC *pvproc, BOOL bFreeVproc);
INT vprocSetImmediatelyTerm(pid_t pid);
@@ -198,7 +201,7 @@ ssize_t vprocGetModsSvr4Info(pid_t pid, PCHAR pcBuff, size_t stMax
VOID vprocThreadAdd(PVOID pvVProc, PLW_CLASS_TCB ptcb);
VOID vprocThreadDelete(PVOID pvVProc, PLW_CLASS_TCB ptcb);
INT vprocThreadNum(pid_t pid, ULONG *pulNum);
-VOID vprocThreadKill(PVOID pvVProc);
+VOID vprocThreadKill(PVOID pvVProc, PLW_CLASS_TCB ptcbExcp);
#if LW_CFG_SIGNAL_EN > 0
INT vprocThreadSigaction(PVOID pvVProc, VOIDFUNCPTR pfunc, INT iSigIndex,
diff --git a/SylixOS/loader/src/loader_vppatch.c b/SylixOS/loader/src/loader_vppatch.c
index ac552eb..82690d8 100644
--- a/SylixOS/loader/src/loader_vppatch.c
+++ b/SylixOS/loader/src/loader_vppatch.c
@@ -103,6 +103,12 @@ INT vprocProcAdd(LW_LD_VPROC *pvproc);
INT vprocProcDelete(LW_LD_VPROC *pvproc);
#endif /* LW_CFG_PROCFS_EN > 0 */
/*********************************************************************************************************
+ POSIX
+*********************************************************************************************************/
+#if LW_CFG_POSIX_EN > 0
+VOID _PthreadKeyCleanup(PLW_CLASS_TCB ptcbDel);
+#endif /* LW_CFG_POSIX_EN > 0 */
+/*********************************************************************************************************
** 函数名称: __moduleVpPatchVersion
** 功能描述: vp 补丁版本
** 输 入 : pmodule 进程主模块句柄
@@ -768,6 +774,85 @@ pid_t vprocGetPidByThread (LW_OBJECT_HANDLE ulId)
return (pid);
}
/*********************************************************************************************************
+** 函数名称: vprocKillPrepare
+** 功能描述: 停止进程内的除主线程外的所有线程.
+** 输 入 : pid 进程号
+** ulId 主线程
+** 输 出 : NONE
+** 全局变量:
+** 调用模块:
+*********************************************************************************************************/
+VOID vprocKillPrepare (pid_t pid, LW_OBJECT_HANDLE ulId)
+{
+ LW_LD_VPROC *pvproc;
+ PLW_LIST_LINE plineTemp;
+ PLW_CLASS_TCB ptcb;
+
+ if (pid > 0 && pid <= LW_CFG_MAX_THREADS) {
+ LW_LD_LOCK();
+ pvproc = _G_pvprocTable[pid - 1];
+ if (pvproc && !pvproc->VP_bKillPrepare) {
+ LW_VP_LOCK(pvproc); /* 锁定目标进程 */
+ pvproc->VP_bKillPrepare = LW_TRUE; /* 删除前需要解锁 */
+
+ LW_LD_UNLOCK();
+ for (plineTemp = pvproc->VP_plineThread;
+ plineTemp != LW_NULL;
+ plineTemp = _list_line_get_next(plineTemp)) {
+
+ ptcb = _LIST_ENTRY(plineTemp, LW_CLASS_TCB, TCB_lineProcess);
+ if (ptcb->TCB_ulId == ulId) {
+ continue; /* 不停止主任务 */
+ }
+
+ __KERNEL_ENTER(); /* 进入内核 */
+ _ThreadStop(ptcb);
+ __KERNEL_EXIT(); /* 退出内核 */
+ }
+ LW_VP_UNLOCK(pvproc); /* 解锁目标进程 */
+
+ } else {
+ LW_LD_UNLOCK();
+ }
+ }
+}
+/*********************************************************************************************************
+** 函数名称: vprocKillRelease
+** 功能描述: 继续运行除主线程以外的其他线程.
+** 输 入 : pid 进程号
+** ulId 主线程
+** 输 出 : NONE
+** 全局变量:
+** 调用模块:
+*********************************************************************************************************/
+static VOID vprocKillRelease (PLW_CLASS_TCB ptcbCur)
+{
+ LW_LD_VPROC *pvproc;
+ PLW_LIST_LINE plineTemp;
+ PLW_CLASS_TCB ptcb;
+
+ pvproc = (LW_LD_VPROC *)ptcbCur->TCB_pvVProcessContext;
+ if (pvproc && pvproc->VP_bKillPrepare) {
+ LW_VP_LOCK(pvproc); /* 锁定目标进程 */
+ pvproc->VP_bKillPrepare = LW_FALSE;
+
+ for (plineTemp = pvproc->VP_plineThread;
+ plineTemp != LW_NULL;
+ plineTemp = _list_line_get_next(plineTemp)) {
+
+ ptcb = _LIST_ENTRY(plineTemp, LW_CLASS_TCB, TCB_lineProcess);
+ if (ptcb == ptcbCur) {
+ continue;
+ }
+
+ __KERNEL_ENTER(); /* 进入内核 */
+ _ThreadContinue(ptcb, LW_FALSE);
+ __KERNEL_EXIT(); /* 退出内核 */
+ }
+ LW_VP_UNLOCK(pvproc); /* 解锁目标进程 */
+ }
+}
+/*********************************************************************************************************
** 函数名称: vprocMainThread
** 功能描述: 通过进程号, 查找对应的主线程.
** 输 入 : pid 进程号
@@ -790,6 +875,28 @@ LW_OBJECT_HANDLE vprocMainThread (pid_t pid)
return (lId);
}
/*********************************************************************************************************
+** 函数名称: vprocCurIsMainThread
+** 功能描述: 当前线程是否为主线程.
+** 输 入 : NONE
+** 输 出 : 是否为主线程
+** 全局变量:
+** 调用模块:
+*********************************************************************************************************/
+BOOL vprocIsMainThread (VOID)
+{
+ PLW_CLASS_TCB ptcbCur;
+ LW_LD_VPROC *pvproc;
+
+ LW_TCB_GET_CUR_SAFE(ptcbCur);
+
+ pvproc = (LW_LD_VPROC *)ptcbCur->TCB_pvVProcessContext;
+ if (pvproc && (pvproc->VP_ulMainThread == ptcbCur->TCB_ulId)) {
+ return (LW_TRUE);
+ }
+
+ return (LW_FALSE);
+}
+/*********************************************************************************************************
** 函数名称: vprocNotifyParent
** 功能描述: 进程通知父系进程
** 输 入 : pvproc 进程控制块指针
@@ -988,16 +1095,20 @@ VOID vprocExit (LW_LD_VPROC *pvproc, LW_OBJECT_HANDLE ulId, INT iCode)
return;
}
-#if LW_CFG_THREAD_EXT_EN > 0
LW_TCB_GET_CUR_SAFE(ptcbCur);
+
__recheck:
+#if LW_CFG_THREAD_EXT_EN > 0
_TCBCleanupPopExt(ptcbCur); /* 提前执行 cleanup pop 操作 */
-#else
-__recheck:
#endif /* LW_CFG_THREAD_EXT_EN > 0 */
+#if LW_CFG_POSIX_EN > 0
+ _PthreadKeyCleanup(ptcbCur); /* 提前执行 key cleanup 操作 */
+#endif /* LW_CFG_POSIX_EN > 0 */
+
if (pvproc->VP_iExitMode == LW_VPROC_EXIT_FORCE) { /* 强制退出删除除主线程外的线程*/
- vprocThreadKill(pvproc);
+ vprocThreadKill(pvproc, ptcbCur);
+ vprocKillRelease(ptcbCur);
}
do { /* 等待所有的线程安全退出 */
diff --git a/SylixOS/loader/src/loader_vpthread.c b/SylixOS/loader/src/loader_vpthread.c
index 6b2de9b..e48a7b4 100644
--- a/SylixOS/loader/src/loader_vpthread.c
+++ b/SylixOS/loader/src/loader_vpthread.c
@@ -108,21 +108,17 @@ INT vprocThreadNum (pid_t pid, ULONG *pulNum)
** 函数名称: vprocThreadKill
** 功能描述: 杀死进程内的除主线程外的所有线程
** 输 入 : pvVProc 进程控制块指针
-** ulThread 线程表
-** uiTableNum 表容量
-** 输 出 : 总线程数
+** ptcbExcp 除此之外
+** 输 出 : NONE
** 全局变量:
** 调用模块:
** 注 意 : 由于此函数中间将释放系统控制权, 所以必须使用 VP_LOCK 保证安全.
*********************************************************************************************************/
-VOID vprocThreadKill (PVOID pvVProc)
+VOID vprocThreadKill (PVOID pvVProc, PLW_CLASS_TCB ptcbExcp)
{
LW_LD_VPROC *pvproc = (LW_LD_VPROC *)pvVProc;
PLW_LIST_LINE plineTemp;
PLW_CLASS_TCB ptcb;
- PLW_CLASS_TCB ptcbCur;
-
- LW_TCB_GET_CUR_SAFE(ptcbCur);
LW_VP_LOCK(pvproc); /* 锁定当前进程 */
for (plineTemp = pvproc->VP_plineThread;
@@ -130,7 +126,7 @@ VOID vprocThreadKill (PVOID pvVProc)
plineTemp = _list_line_get_next(plineTemp)) {
ptcb = _LIST_ENTRY(plineTemp, LW_CLASS_TCB, TCB_lineProcess);
- if (ptcb != ptcbCur) { /* ptcbCur 为主线程 */
+ if (ptcb != ptcbExcp) { /* ptcbCur 为主线程 */
_excJobAdd((VOIDFUNCPTR)kill, (PVOID)ptcb->TCB_ulId, (PVOID)SIGKILL, 0, 0, 0, 0);
}
}
diff --git a/SylixOS/net/lwip/bonding/netbonding.c b/SylixOS/net/lwip/bonding/netbonding.c
index db7ec9a..089a7ea 100644
--- a/SylixOS/net/lwip/bonding/netbonding.c
+++ b/SylixOS/net/lwip/bonding/netbonding.c
@@ -506,7 +506,7 @@ int netbd_add_dev (const char *bddev, const char *sub, int sub_is_ifname)
found = 1;
}
}
- if (!found || netif->ext_eth || (netdev->net_type != NETDEV_TYPE_ETHERNET)) {
+ if (!found || netif->ext_ctl || (netdev->net_type != NETDEV_TYPE_ETHERNET)) {
LWIP_IF_LIST_UNLOCK();
errno = ENXIO;
return (-1);
@@ -572,6 +572,7 @@ int netbd_add_dev (const char *bddev, const char *sub, int sub_is_ifname)
netbd_eth->input = netif->input; /* save the old input function */
netif->input = netbd_input; /* set new input function */
netif->ext_eth = (void *)netbd_eth;
+ netif->ext_ctl = (void *)netbd;
if (need_up) {
netifapi_netif_set_up(netif_bd); /* make bonding up */
@@ -706,7 +707,7 @@ int netbd_delete_dev (const char *bddev, const char *sub, int sub_is_ifname)
NETBD_UNLOCK(netbd);
netif->input = netbd_eth->input; /* restore old input function */
- netif->ext_eth = NULL;
+ netif->ext_ctl = netif->ext_eth = NULL;
mem_free(netbd_eth);
@@ -1102,7 +1103,7 @@ int netbd_delete (const char *bddev)
}
netif->input = netbd_eth->input; /* restore input function */
- netif->ext_eth = NULL;
+ netif->ext_ctl = netif->ext_eth = NULL;
mem_free(netbd_eth);
@@ -1133,7 +1134,8 @@ int netbd_delete (const char *bddev)
return (0);
}
-/* net bonding sub device delete hook */
+/* net bonding sub device delete hook
+ NOTICE: this is in LWIP_IF_LIST_LOCK status */
void netbd_sub_delete_hook (netdev_t *netdev)
{
int i, flags;
@@ -1142,11 +1144,9 @@ void netbd_sub_delete_hook (netdev_t *netdev)
netbd_eth_t *netbd_eth;
struct ifreq ifreq;
- LWIP_IF_LIST_LOCK(FALSE);
netif = (struct netif *)netdev->sys;
- netbd = (netbd_t *)netif->ext_eth;
+ netbd = (netbd_t *)netif->ext_ctl;
if (!netbd || netbd->magic_no != NETBONDING_MAGIC) {
- LWIP_IF_LIST_UNLOCK();
return;
}
netbd_eth = (netbd_eth_t *)netbd->eth_ring;
@@ -1157,10 +1157,8 @@ void netbd_sub_delete_hook (netdev_t *netdev)
netbd_eth = (netbd_eth_t *)_list_ring_get_next(&netbd_eth->ring);
}
if (i >= netbd->eth_cnt) {
- LWIP_IF_LIST_UNLOCK();
return;
}
- LWIP_IF_LIST_UNLOCK();
if (netif->flags & NETIF_FLAG_UP) {
netif->flags &= ~NETIF_FLAG_UP;
@@ -1202,7 +1200,7 @@ void netbd_sub_delete_hook (netdev_t *netdev)
NETBD_UNLOCK(netbd);
netif->input = netbd_eth->input; /* restore old input function */
- netif->ext_eth = NULL;
+ netif->ext_ctl = netif->ext_eth = NULL;
mem_free(netbd_eth);
}
diff --git a/SylixOS/net/lwip/bridge/netbridge.c b/SylixOS/net/lwip/bridge/netbridge.c
index 3d0724a..51388fb 100644
--- a/SylixOS/net/lwip/bridge/netbridge.c
+++ b/SylixOS/net/lwip/bridge/netbridge.c
@@ -386,7 +386,7 @@ int netbr_add_dev (const char *brdev, const char *sub, int sub_is_ifname)
found = 1;
}
}
- if (!found || netif->ext_eth || (netdev->net_type != NETDEV_TYPE_ETHERNET)) {
+ if (!found || netif->ext_ctl || (netdev->net_type != NETDEV_TYPE_ETHERNET)) {
LWIP_IF_LIST_UNLOCK();
errno = ENXIO;
return (-1);
@@ -434,7 +434,8 @@ int netbr_add_dev (const char *brdev, const char *sub, int sub_is_ifname)
netbr_eth->input = netif->input; /* save the old input function */
netif->input = netbr_input; /* set new input function */
netif->ext_eth = (void *)netbr_eth;
-
+ netif->ext_ctl = (void *)netbr;
+
if (need_up) {
netifapi_netif_set_up(netif_br); /* make bridge up */
}
@@ -551,7 +552,7 @@ int netbr_delete_dev (const char *brdev, const char *sub, int sub_is_ifname)
NETBR_UNLOCK(netbr);
netif->input = netbr_eth->input; /* restore old input function */
- netif->ext_eth = NULL;
+ netif->ext_ctl = netif->ext_eth = NULL;
mem_free(netbr_eth);
@@ -712,7 +713,7 @@ int netbr_delete (const char *brdev)
}
netif->input = netbr_eth->input; /* restore input function */
- netif->ext_eth = NULL;
+ netif->ext_ctl = netif->ext_eth = NULL;
mem_free(netbr_eth);
@@ -787,7 +788,8 @@ int netbr_flush_cache (const char *brdev)
return (0);
}
-/* net bridge sub device delete hook */
+/* net bridge sub device delete hook
+ NOTICE: this is in LWIP_IF_LIST_LOCK status */
void netbr_sub_delete_hook (netdev_t *netdev)
{
int flags;
@@ -797,11 +799,9 @@ void netbr_sub_delete_hook (netdev_t *netdev)
struct ifreq ifreq;
LW_LIST_LINE *pline;
- LWIP_IF_LIST_LOCK(FALSE);
netif = (struct netif *)netdev->sys;
- netbr = (netbr_t *)netif->ext_eth;
+ netbr = (netbr_t *)netif->ext_ctl;
if (!netbr || netbr->magic_no != NETBRIDGE_MAGIC) {
- LWIP_IF_LIST_UNLOCK();
return;
}
for (pline = netbr->eth_list; pline != NULL; pline = _list_line_get_next(pline)) {
@@ -811,10 +811,8 @@ void netbr_sub_delete_hook (netdev_t *netdev)
}
}
if (!pline) {
- LWIP_IF_LIST_UNLOCK();
return;
}
- LWIP_IF_LIST_UNLOCK();
if (netif->flags & NETIF_FLAG_UP) {
netif->flags &= ~NETIF_FLAG_UP;
@@ -841,7 +839,7 @@ void netbr_sub_delete_hook (netdev_t *netdev)
NETBR_UNLOCK(netbr);
netif->input = netbr_eth->input; /* restore old input function */
- netif->ext_eth = NULL;
+ netif->ext_ctl = netif->ext_eth = NULL;
mem_free(netbr_eth);
}
diff --git a/SylixOS/net/lwip/netdev/netdev.c b/SylixOS/net/lwip/netdev/netdev.c
index 960c8f7..9d49483 100644
--- a/SylixOS/net/lwip/netdev/netdev.c
+++ b/SylixOS/net/lwip/netdev/netdev.c
@@ -562,10 +562,11 @@ static void netdev_netif_set_linkup (netdev_t *netdev, int linkup, UINT32 speed
netif->ts = sys_jiffies();
netdev->speed = speed;
- if (!netif->ext_eth) { /* not in net bridge or bonding */
+ if (!netif->ext_ctl) { /* not in net bridge or bonding */
netifapi_netif_set_link_up(netif);
} else {
netif_set_flags(netif, NETIF_FLAG_LINK_UP);
+ netdev_netif_linkup(netif);
}
if (speed > 0xffffffff) {
@@ -575,10 +576,11 @@ static void netdev_netif_set_linkup (netdev_t *netdev, int linkup, UINT32 speed
}
} else {
- if (!netif->ext_eth) { /* not in net bridge or bonding */
+ if (!netif->ext_ctl) { /* not in net bridge or bonding */
netifapi_netif_set_link_down(netif);
} else {
netif_clear_flags(netif, NETIF_FLAG_LINK_UP);
+ netdev_netif_linkup(netif);
}
}
@@ -1054,6 +1056,8 @@ int netdev_delete (netdev_t *netdev)
netif = (struct netif *)netdev->sys;
+ LWIP_IF_LIST_LOCK(LW_TRUE);
+
#if LW_CFG_NET_DEV_BRIDGE_EN > 0
netbr_sub_delete_hook(netdev);
#endif /* LW_CFG_NET_DEV_BONDING_EN > 0 */
@@ -1062,7 +1066,6 @@ int netdev_delete (netdev_t *netdev)
netbd_sub_delete_hook(netdev);
#endif /* LW_CFG_NET_DEV_BONDING_EN > 0 */
- LWIP_IF_LIST_LOCK(LW_TRUE);
NETIF_FOREACH(tmp_netif) {
if (tmp_netif == netif) {
break;
diff --git a/SylixOS/net/lwip/src/core/netif.c b/SylixOS/net/lwip/src/core/netif.c
index 442a84b..fdf04ac 100644
--- a/SylixOS/net/lwip/src/core/netif.c
+++ b/SylixOS/net/lwip/src/core/netif.c
@@ -384,6 +384,7 @@ netif_add(struct netif *netif,
netif->flags2 = 0;
netif->priv_flags = 0;
netif->ext_eth = NULL;
+ netif->ext_ctl = NULL;
netif->flowctl = NULL;
netif->vlanid = (u16_t)-1;
netif->metric = 1;
diff --git a/SylixOS/posix/pthread/pthread_key.c b/SylixOS/posix/pthread/pthread_key.c
index f05c8b7..16f610a 100644
--- a/SylixOS/posix/pthread/pthread_key.c
+++ b/SylixOS/posix/pthread/pthread_key.c
@@ -288,6 +288,24 @@ __re_check:
__PX_UNLOCK(); /* 解锁 posix 库 */
}
/*********************************************************************************************************
+** 函数名称: _PthreadKeyCleanup
+** 功能描述: 删除所有与当前线程相关的内部数据节点.
+** 输 入 : pkey 键 (返回)
+** fdestructor 删除函数
+** 输 出 : ERROR CODE
+** 全局变量:
+** 调用模块:
+** 注 意 : 进程回收内存空间之前会预先调用此函数.
+*********************************************************************************************************/
+#if LW_CFG_MODULELOADER_EN > 0
+
+VOID _PthreadKeyCleanup (PLW_CLASS_TCB ptcbDel)
+{
+ __pthreadDataDeleteByThread(ptcbDel->TCB_ulId, LW_NULL, ptcbDel);
+}
+
+#endif /* LW_CFG_MODULELOADER_EN > 0 */
+/*********************************************************************************************************
** 函数名称: pthread_key_create
** 功能描述: 创建一个数据键.
** 输 入 : pkey 键 (返回)
diff --git a/SylixOS/shell/ttinyShell/ttinyShellLib.c b/SylixOS/shell/ttinyShell/ttinyShellLib.c
index 5301fc6..9999986 100644
--- a/SylixOS/shell/ttinyShell/ttinyShellLib.c
+++ b/SylixOS/shell/ttinyShell/ttinyShellLib.c
@@ -91,6 +91,12 @@
#include "../SylixOS/shell/hashLib/hashHorner.h"
#include "../SylixOS/shell/ttinyVar/ttinyVarLib.h"
/*********************************************************************************************************
+ 内部进程相关函数声明
+*********************************************************************************************************/
+#if LW_CFG_MODULELOADER_EN > 0
+#include "../SylixOS/loader/include/loader_vppatch.h"
+#endif /* LW_CFG_MODULELOADER_EN > 0 */
+/*********************************************************************************************************
背景控制 (t_shell 线程中通过接收的命令字符串末尾判断)
*********************************************************************************************************/
#define __TTINY_SHELL_BG_ASYNC '&' /* 背景异步执行 */
@@ -841,7 +847,15 @@ INT __tshellRestartEx (LW_OBJECT_HANDLE ulThread, BOOL bNeedAuthen)
if (ulJoin) {
#if LW_CFG_SIGNAL_EN > 0
- kill(ulJoin, SIGKILL); /* 杀死等待的线程/进程 */
+#if LW_CFG_MODULELOADER_EN > 0
+ pid_t pid = vprocGetPidByThread(ulJoin);
+ if (pid > 0) {
+ kill(pid, SIGKILL); /* 杀死等待的进程 */
+ } else
+#endif /* LW_CFG_MODULELOADER_EN > 0 */
+ {
+ kill(ulJoin, SIGKILL); /* 杀死等待的线程 */
+ }
#else
API_ThreadDelete(&ulJoin, LW_NULL);
#endif /* LW_CFG_SIGNAL_EN > 0 */
diff --git a/SylixOS/shell/ttinyShell/ttinyShellSysCmd.c b/SylixOS/shell/ttinyShell/ttinyShellSysCmd.c
index c26be34..4e2430e 100644
--- a/SylixOS/shell/ttinyShell/ttinyShellSysCmd.c
+++ b/SylixOS/shell/ttinyShell/ttinyShellSysCmd.c
@@ -892,7 +892,7 @@ static INT __tshellSysCmdMems (INT iArgC, PCHAR ppcArgV[])
static INT __tshellSysCmdKill (INT iArgC, PCHAR ppcArgV[])
{
LW_OBJECT_HANDLE ulId = LW_OBJECT_HANDLE_INVALID;
- INT iSigNum = SIGTERM;
+ INT iSigNum = SIGKILL;
if (iArgC == 2) {
if (ppcArgV[1][0] < '0' ||
@@ -937,7 +937,7 @@ static INT __tshellSysCmdKill (INT iArgC, PCHAR ppcArgV[])
static INT __tshellSysCmdSigqueue (INT iArgC, PCHAR ppcArgV[])
{
LW_OBJECT_HANDLE ulId = LW_OBJECT_HANDLE_INVALID;
- INT iSigNum = SIGTERM;
+ INT iSigNum = SIGKILL;
union sigval sigvalue;
sigvalue.sival_int = 0;
diff --git a/SylixOS/system/signal/signal.c b/SylixOS/system/signal/signal.c
index 47fc3aa..ac617cc 100644
--- a/SylixOS/system/signal/signal.c
+++ b/SylixOS/system/signal/signal.c
@@ -834,8 +834,13 @@ INT kill (LW_OBJECT_HANDLE ulId, INT iSigNo)
#endif
#if LW_CFG_MODULELOADER_EN > 0
+ pid_t pid;
+
if (ulId <= LW_CFG_MAX_THREADS) { /* 进程号 */
+ pid = (pid_t)ulId;
ulId = vprocMainThread((pid_t)ulId);
+ } else {
+ pid = 0;
}
#endif /* LW_CFG_MODULELOADER_EN > 0 */
@@ -870,6 +875,12 @@ INT kill (LW_OBJECT_HANDLE ulId, INT iSigNo)
}
#endif /* LW_CFG_SMP_EN */
+#if LW_CFG_MODULELOADER_EN > 0
+ if ((iSigNo == SIGKILL) && (pid > 0)) {
+ vprocKillPrepare(pid, ulId); /* 进程 KILL 预处理 */
+ }
+#endif /* LW_CFG_MODULELOADER_EN > 0 */
+
__KERNEL_ENTER(); /* 进入内核 */
if (_Thread_Invalid(usIndex)) {
__KERNEL_EXIT(); /* 退出内核 */
@@ -947,8 +958,13 @@ static INT __sigqueue (LW_OBJECT_HANDLE ulId, INT iSigNo, PVOID psigvalue)
sigvalue.sival_ptr = psigvalue;
#if LW_CFG_MODULELOADER_EN > 0
+ pid_t pid;
+
if (ulId <= LW_CFG_MAX_THREADS) { /* 进程号 */
+ pid = (pid_t)ulId;
ulId = vprocMainThread((pid_t)ulId);
+ } else {
+ pid = 0;
}
#endif /* LW_CFG_MODULELOADER_EN > 0 */
@@ -970,6 +986,12 @@ static INT __sigqueue (LW_OBJECT_HANDLE ulId, INT iSigNo, PVOID psigvalue)
}
#endif /* LW_CFG_SMP_EN */
+#if LW_CFG_MODULELOADER_EN > 0
+ if ((iSigNo == SIGKILL) && (pid > 0)) {
+ vprocKillPrepare(pid, ulId); /* 进程 KILL 预处理 */
+ }
+#endif /* LW_CFG_MODULELOADER_EN > 0 */
+
__KERNEL_ENTER(); /* 进入内核 */
if (_Thread_Invalid(usIndex)) {
__KERNEL_EXIT(); /* 退出内核 */
diff --git a/SylixOS/system/signal/signalEvent.c b/SylixOS/system/signal/signalEvent.c
index aac3772..cf11c62 100644
--- a/SylixOS/system/signal/signalEvent.c
+++ b/SylixOS/system/signal/signalEvent.c
@@ -150,6 +150,9 @@ static INT _doSigEventInternal (LW_OBJECT_HANDLE ulId, PSIGNAL_EVENT_ARG psi
#if LW_CFG_SIGNALFD_EN > 0
LW_SEND_VAL sendval;
#endif
+#if LW_CFG_MODULELOADER_EN > 0
+ pid_t pid;
+#endif /* LW_CFG_MODULELOADER_EN > 0 */
struct sigevent *psigevent = &psigea->SE_event.SE_sigevent;
struct siginfo *psiginfo = &psigea->SE_event.SE_siginfo;
@@ -170,7 +173,10 @@ static INT _doSigEventInternal (LW_OBJECT_HANDLE ulId, PSIGNAL_EVENT_ARG psi
#if LW_CFG_MODULELOADER_EN > 0
if (ulId <= LW_CFG_MAX_THREADS) { /* 进程号 */
+ pid = (pid_t)ulId;
ulId = vprocMainThread((pid_t)ulId);
+ } else {
+ pid = 0;
}
#endif /* LW_CFG_MODULELOADER_EN > 0 */
@@ -213,6 +219,12 @@ static INT _doSigEventInternal (LW_OBJECT_HANDLE ulId, PSIGNAL_EVENT_ARG psi
}
#endif /* LW_CFG_SMP_EN */
+#if LW_CFG_MODULELOADER_EN > 0
+ if ((psigevent->sigev_signo == SIGKILL) && (pid > 0)) {
+ vprocKillPrepare(pid, ulId); /* 进程 KILL 预处理 */
+ }
+#endif /* LW_CFG_MODULELOADER_EN > 0 */
+
__KERNEL_ENTER(); /* 进入内核 */
if (_Thread_Invalid(usIndex)) {
__KERNEL_EXIT(); /* 退出内核 */
diff --git a/SylixOS/system/signal/signalLib.c b/SylixOS/system/signal/signalLib.c
index 85f4f04..8d633a8 100644
--- a/SylixOS/system/signal/signalLib.c
+++ b/SylixOS/system/signal/signalLib.c
@@ -115,20 +115,16 @@ static BOOL _sigPendRunSelf(VOID);
/*********************************************************************************************************
** 函数名称: __signalCnclHandle
** 功能描述: SIGCNCL 信号的服务函数
-** 输 入 : iSigNo 信号数值
+** 输 入 : ptcbCur 当前任务
+** iSigNo 信号数值
** psiginfo 信号信息
** 输 出 : NONE
** 全局变量:
** 调用模块:
*********************************************************************************************************/
-static VOID __signalCnclHandle (INT iSigNo, struct siginfo *psiginfo)
+static VOID __signalCnclHandle (PLW_CLASS_TCB ptcbCur, INT iSigNo, struct siginfo *psiginfo)
{
- LW_OBJECT_HANDLE ulId;
- PLW_CLASS_TCB ptcbCur;
-
- LW_TCB_GET_CUR_SAFE(ptcbCur);
-
- ulId = ptcbCur->TCB_ulId;
+ LW_OBJECT_HANDLE ulId = ptcbCur->TCB_ulId;
if (ptcbCur->TCB_iCancelState == LW_THREAD_CANCEL_ENABLE &&
ptcbCur->TCB_iCancelType == LW_THREAD_CANCEL_DEFERRED &&
@@ -142,30 +138,19 @@ static VOID __signalCnclHandle (INT iSigNo, struct siginfo *psiginfo)
}
/*********************************************************************************************************
** 函数名称: __signalExitHandle
-** 功能描述: SIGCANCEL 信号的服务函数
-** 输 入 : iSigNo 信号数值
+** 功能描述: 需要进程退出的信号的服务函数
+** 输 入 : ptcbCur 当前任务
+** iSigNo 信号数值
** psiginfo 信号信息
** 输 出 : NONE
** 全局变量:
** 调用模块:
*********************************************************************************************************/
-static VOID __signalExitHandle (INT iSigNo, struct siginfo *psiginfo)
+static VOID __signalExitHandle (PLW_CLASS_TCB ptcbCur, INT iSigNo, struct siginfo *psiginfo)
{
- LW_OBJECT_HANDLE ulId;
- PLW_CLASS_TCB ptcbCur;
+ LW_OBJECT_HANDLE ulId = ptcbCur->TCB_ulId;
#if LW_CFG_MODULELOADER_EN > 0
- pid_t pid = getpid();
-#endif /* LW_CFG_MODULELOADER_EN > 0 */
-
- LW_TCB_GET_CUR_SAFE(ptcbCur);
-
- ulId = ptcbCur->TCB_ulId;
-
-#if LW_CFG_MODULELOADER_EN > 0
- if ((pid > 0) && (iSigNo != SIGTERM)) {
- vprocExitModeSet(pid, LW_VPROC_EXIT_FORCE); /* 强制进程退出 */
- vprocSetImmediatelyTerm(pid); /* 立即退出模式 */
- }
+ pid_t pid = vprocGetPidByTcb(ptcbCur);
#endif /* LW_CFG_MODULELOADER_EN > 0 */
if ((iSigNo == SIGBUS) ||
@@ -173,28 +158,64 @@ static VOID __signalExitHandle (INT iSigNo, struct siginfo *psiginfo)
(iSigNo == SIGSEGV) ||
(iSigNo == SIGILL) ||
(iSigNo == SIGFPE) ||
- (iSigNo == SIGSYS)) {
+ (iSigNo == SIGSYS)) { /* 整个进程需要退出 */
#if LW_CFG_MODULELOADER_EN > 0
+ if (pid > 0) {
+ vprocExitModeSet(pid, LW_VPROC_EXIT_FORCE); /* 强制进程退出 */
+ vprocSetImmediatelyTerm(pid); /* 立即退出模式 */
+ }
__LW_FATAL_ERROR_HOOK(pid, ulId, psiginfo); /* 关键性异常 */
#else
__LW_FATAL_ERROR_HOOK(0, ulId, psiginfo); /* 关键性异常 */
#endif /* LW_CFG_MODULELOADER_EN > 0 */
_exit(psiginfo->si_int);
- } else { /* 非关键性异常 */
- API_ThreadDelete(&ulId, (PVOID)psiginfo->si_int); /* 删除自己 */
- } /* 如果在安全模式, 则退出安全 */
+ } else if (iSigNo != SIGTERM) { /* 仅删除当前线程 */
+ if (pid > 0 && vprocIsMainThread()) {
+ vprocExitModeSet(pid, LW_VPROC_EXIT_FORCE); /* 强制进程退出 */
+ vprocSetImmediatelyTerm(pid); /* 立即退出模式 */
+ }
+ }
+ /* 删除自己 */
+ API_ThreadDelete(&ulId, (PVOID)psiginfo->si_int); /* 如果在安全模式, 则退出安全 */
} /* 模式后, 自动被删除 */
/*********************************************************************************************************
+** 函数名称: __signalKillHandle
+** 功能描述: SIGKILL 信号的服务函数
+** 输 入 : ptcbCur 当前任务
+** iSigNo 信号数值
+** psiginfo 信号信息
+** 输 出 : NONE
+** 全局变量:
+** 调用模块:
+*********************************************************************************************************/
+#if LW_CFG_MODULELOADER_EN > 0
+
+static VOID __signalKillHandle (PLW_CLASS_TCB ptcbCur, INT iSigNo, struct siginfo *psiginfo)
+{
+ LW_OBJECT_HANDLE ulId = ptcbCur->TCB_ulId;
+ pid_t pid = vprocGetPidByTcb(ptcbCur);
+
+ if (pid > 0 && vprocIsMainThread()) {
+ vprocExitModeSet(pid, LW_VPROC_EXIT_FORCE); /* 强制进程退出 */
+ vprocSetImmediatelyTerm(pid); /* 立即退出模式 */
+ }
+
+ API_ThreadDelete(&ulId, (PVOID)psiginfo->si_int); /* 删除自己 */
+}
+
+#endif /* LW_CFG_MODULELOADER_EN > 0 */
+/*********************************************************************************************************
** 函数名称: __signalWaitHandle
** 功能描述: 回收子进程资源
-** 输 入 : iSigNo 信号数值
+** 输 入 : ptcbCur 当前任务
+** iSigNo 信号数值
** psiginfo 信号信息
** 输 出 : NONE
** 全局变量:
** 调用模块:
*********************************************************************************************************/
-static VOID __signalWaitHandle (INT iSigNo, struct siginfo *psiginfo)
+static VOID __signalWaitHandle (PLW_CLASS_TCB ptcbCur, INT iSigNo, struct siginfo *psiginfo)
{
#if LW_CFG_MODULELOADER_EN > 0
reclaimchild(psiginfo->si_pid);
@@ -203,18 +224,19 @@ static VOID __signalWaitHandle (INT iSigNo, struct siginfo *psiginfo)
/*********************************************************************************************************
** 函数名称: __signalStopHandle
** 功能描述: SIGSTOP / SIGTSTP 信号的服务函数
-** 输 入 : iSigNo 信号数值
+** 输 入 : ptcbCur 当前任务
+** iSigNo 信号数值
** psiginfo 信号信息
** 输 出 : NONE
** 全局变量:
** 调用模块:
*********************************************************************************************************/
-static VOID __signalStopHandle (INT iSigNo, struct siginfo *psiginfo)
+static VOID __signalStopHandle (PLW_CLASS_TCB ptcbCur, INT iSigNo, struct siginfo *psiginfo)
{
sigset_t sigsetMask;
#if LW_CFG_MODULELOADER_EN > 0
- LW_LD_VPROC *pvproc = __LW_VP_GET_CUR_PROC();
+ LW_LD_VPROC *pvproc = __LW_VP_GET_TCB_PROC(ptcbCur);
#endif /* LW_CFG_MODULELOADER_EN */
sigsetMask = ~__SIGNO_UNMASK;
@@ -238,12 +260,13 @@ static VOID __signalStopHandle (INT iSigNo, struct siginfo *psiginfo)
/*********************************************************************************************************
** 函数名称: __signalStkShowHandle
** 功能描述: 打印上下文服务函数
-** 输 入 : psigctlmsg 信号控制信息
+** 输 入 : ptcbCur 当前任务
+** psigctlmsg 信号控制信息
** 输 出 : NONE
** 全局变量:
** 调用模块:
*********************************************************************************************************/
-static VOID __signalStkShowHandle (PLW_CLASS_SIGCTLMSG psigctlmsg)
+static VOID __signalStkShowHandle (PLW_CLASS_TCB ptcbCur, PLW_CLASS_SIGCTLMSG psigctlmsg)
{
#if LW_CFG_ABORT_CALLSTACK_INFO_EN > 0
API_BacktraceShow(STD_OUT, 100);
@@ -617,11 +640,13 @@ static VOID __sigRunHandle (PLW_CLASS_SIGCONTEXT psigctx,
PLW_CLASS_SIGCTLMSG psigctlmsg)
{
REGISTER struct sigaction *psigaction;
-
+ PLW_CLASS_TCB ptcbCur;
REGISTER VOIDFUNCPTR pfuncHandle;
PVOID pvCtx;
__KERNEL_ENTER(); /* 进入内核 */
+ LW_TCB_GET_CUR(ptcbCur); /* 获得当前 TCB */
+
psigaction = &psigctx->SIGCTX_sigaction[__sigindex(iSigNo)];
pfuncHandle = (VOIDFUNCPTR)psigaction->sa_handler; /* 获得信号执行函数句柄 */
@@ -630,70 +655,78 @@ static VOID __sigRunHandle (PLW_CLASS_SIGCONTEXT psigctx,
}
__KERNEL_EXIT(); /* 退出内核 */
- if ((pfuncHandle != SIG_IGN) &&
- (pfuncHandle != SIG_ERR) &&
- (pfuncHandle != SIG_DFL) &&
- (pfuncHandle != SIG_CATCH) &&
- (pfuncHandle != SIG_HOLD)) {
- pvCtx = (psigctlmsg)
- ? &psigctlmsg->SIGCTLMSG_archRegCtx
- : LW_NULL;
-
- if (psigaction->sa_flags & SA_SIGINFO) { /* 需要 siginfo_t 信息 */
- LW_SOFUNC_PREPARE(pfuncHandle);
- pfuncHandle(iSigNo, psiginfo, pvCtx); /* 执行信号句柄 */
-
- } else {
- LW_SOFUNC_PREPARE(pfuncHandle);
- pfuncHandle(iSigNo, pvCtx); /* XXX 是否传入 pvCtx 参数 ? */
- }
-
- if (__SIGNO_MUST_EXIT & __sigmask(iSigNo)) { /* 必须退出 */
- __signalExitHandle(iSigNo, psiginfo);
+#if LW_CFG_MODULELOADER_EN > 0 /* 进程 KILL 不执行安装句柄 */
+ if (iSigNo == SIGKILL && __LW_VP_GET_TCB_PROC(ptcbCur)) {
+ __signalKillHandle(ptcbCur, iSigNo, psiginfo); /* 立即退出 */
+
+ } else
+#endif /* LW_CFG_MODULELOADER_EN > 0 */
+ {
+ if ((pfuncHandle != SIG_IGN) &&
+ (pfuncHandle != SIG_ERR) &&
+ (pfuncHandle != SIG_DFL) &&
+ (pfuncHandle != SIG_CATCH) &&
+ (pfuncHandle != SIG_HOLD)) { /* 需要执行用户句柄 */
+ pvCtx = (psigctlmsg)
+ ? &psigctlmsg->SIGCTLMSG_archRegCtx
+ : LW_NULL;
+
+ if (psigaction->sa_flags & SA_SIGINFO) { /* 需要 siginfo_t 信息 */
+ LW_SOFUNC_PREPARE(pfuncHandle);
+ pfuncHandle(iSigNo, psiginfo, pvCtx); /* 执行信号句柄 */
+
+ } else {
+ LW_SOFUNC_PREPARE(pfuncHandle);
+ pfuncHandle(iSigNo, pvCtx); /* XXX 是否传入 pvCtx 参数 ? */
+ }
- } else if (iSigNo == SIGCNCL) { /* 线程取消信号 */
- __signalCnclHandle(iSigNo, psiginfo);
- }
-
- } else {
- switch (iSigNo) { /* 默认处理句柄 */
+ if (__SIGNO_MUST_EXIT & __sigmask(iSigNo)) { /* 必须退出 */
+ __signalExitHandle(ptcbCur, iSigNo, psiginfo);
+
+ } else if (iSigNo == SIGCNCL) { /* 线程取消信号 */
+ __signalCnclHandle(ptcbCur, iSigNo, psiginfo);
+ }
- case SIGINT:
- case SIGQUIT:
- case SIGFPE:
- case SIGKILL:
- case SIGBUS:
- case SIGTERM:
- case SIGABRT:
- case SIGILL:
- case SIGSEGV:
- case SIGSYS:
- __signalExitHandle(iSigNo, psiginfo);
- break;
-
- case SIGSTOP:
- case SIGTSTP:
- __signalStopHandle(iSigNo, psiginfo);
- break;
+ } else { /* 其他处理 */
+ switch (iSigNo) { /* 默认处理句柄 */
- case SIGCHLD:
- if ((psiginfo->si_code == CLD_EXITED) ||
- (psiginfo->si_code == CLD_KILLED) ||
- (psiginfo->si_code == CLD_DUMPED)) { /* 回收子进程资源 */
- __signalWaitHandle(iSigNo, psiginfo);
+ case SIGINT:
+ case SIGQUIT:
+ case SIGFPE:
+ case SIGKILL:
+ case SIGBUS:
+ case SIGTERM:
+ case SIGABRT:
+ case SIGILL:
+ case SIGSEGV:
+ case SIGSYS:
+ __signalExitHandle(ptcbCur, iSigNo, psiginfo);
+ break;
+
+ case SIGSTOP:
+ case SIGTSTP:
+ __signalStopHandle(ptcbCur, iSigNo, psiginfo);
+ break;
+
+ case SIGCHLD:
+ if ((psiginfo->si_code == CLD_EXITED) ||
+ (psiginfo->si_code == CLD_KILLED) ||
+ (psiginfo->si_code == CLD_DUMPED)) { /* 回收子进程资源 */
+ __signalWaitHandle(ptcbCur, iSigNo, psiginfo);
+ }
+ break;
+
+ case SIGCNCL:
+ __signalCnclHandle(ptcbCur, iSigNo, psiginfo);
+ break;
+
+ case SIGSTKSHOW:
+ __signalStkShowHandle(ptcbCur, psigctlmsg);
+ break;
+
+ default:
+ break;
}
- break;
-
- case SIGCNCL:
- __signalCnclHandle(iSigNo, psiginfo);
- break;
-
- case SIGSTKSHOW:
- __signalStkShowHandle(psigctlmsg);
- break;
-
- default:
- break;
}
}
}