Skip to content

Commit e3804fa

Browse files
committed
signals: fix build and runtime issues when signals all isabled
Fix build and runtime issues when signals all disabled. Signed-off-by: Chengdong Wang <[email protected]>
1 parent 60d814e commit e3804fa

File tree

10 files changed

+63
-27
lines changed

10 files changed

+63
-27
lines changed

examples/ipforward/ipforward.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -840,7 +840,12 @@ int main(int argc, FAR char *argv[])
840840

841841
/* Wait for receiver thread to terminate */
842842

843+
#ifndef CONFIG_DISABLE_ALL_SIGNALS
843844
pthread_kill(fwd.if_receiver, 9);
845+
#else
846+
pthread_cancel(fwd.if_receiver);
847+
#endif
848+
844849
ret = pthread_join(fwd.if_receiver, &value);
845850
if (ret != OK)
846851
{

examples/usrsocktest/usrsocktest_wake_with_signal.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,8 +560,11 @@ static void do_wake_test(enum e_test_type type, int flags)
560560

561561
for (tidx = 0; tidx < nthreads; tidx++)
562562
{
563+
#ifndef CONFIG_DISABLE_ALL_SIGNALS
563564
pthread_kill(tid[tidx], SIGUSR1);
564-
565+
#else
566+
pthread_cancel(tid[tidx]);
567+
#endif
565568
/* Wait threads to complete work. */
566569

567570
ret = pthread_join(tid[tidx], NULL);

nshlib/nsh.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,6 +1179,7 @@ int cmd_switchboot(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv);
11791179
int cmd_unset(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv);
11801180
#endif
11811181

1182+
#ifndef CONFIG_DISABLE_ALL_SIGNALS
11821183
#ifndef CONFIG_NSH_DISABLE_KILL
11831184
int cmd_kill(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv);
11841185
#endif
@@ -1191,6 +1192,7 @@ int cmd_switchboot(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv);
11911192
#ifndef CONFIG_NSH_DISABLE_USLEEP
11921193
int cmd_usleep(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv);
11931194
#endif
1195+
#endif /* !CONFIG_DISABLE_ALL_SIGNALS */
11941196

11951197
#ifndef CONFIG_NSH_DISABLE_UPTIME
11961198
int cmd_uptime(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv);

nshlib/nsh_command.c

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -304,14 +304,6 @@ static const struct cmdmap_s g_cmdmap[] =
304304
CMD_MAP("irqinfo", cmd_irqinfo, 1, 1, NULL),
305305
#endif
306306

307-
#ifndef CONFIG_NSH_DISABLE_KILL
308-
CMD_MAP("kill", cmd_kill, 2, 3, "[-<signal>] <pid>"),
309-
#endif
310-
311-
#if defined(CONFIG_FS_PROCFS) && !defined(CONFIG_NSH_DISABLE_PKILL)
312-
CMD_MAP("pkill", cmd_pkill, 2, 3, "[-<signal>] <name>"),
313-
#endif
314-
315307
#ifndef CONFIG_DISABLE_MOUNTPOINT
316308
# if defined(CONFIG_DEV_LOOP) && !defined(CONFIG_NSH_DISABLE_LOSETUP)
317309
CMD_MAP("losetup", cmd_losetup, 3, 6,
@@ -575,10 +567,24 @@ static const struct cmdmap_s g_cmdmap[] =
575567
#endif
576568
#endif
577569

570+
#ifndef CONFIG_DISABLE_ALL_SIGNALS
571+
#ifndef CONFIG_NSH_DISABLE_KILL
572+
CMD_MAP("kill", cmd_kill, 2, 3, "[-<signal>] <pid>"),
573+
#endif
574+
575+
#if defined(CONFIG_FS_PROCFS) && !defined(CONFIG_NSH_DISABLE_PKILL)
576+
CMD_MAP("pkill", cmd_pkill, 2, 3, "[-<signal>] <name>"),
577+
#endif
578+
578579
#ifndef CONFIG_NSH_DISABLE_SLEEP
579580
CMD_MAP("sleep", cmd_sleep, 2, 2, "<sec>"),
580581
#endif
581582

583+
#ifndef CONFIG_NSH_DISABLE_USLEEP
584+
CMD_MAP("usleep", cmd_usleep, 2, 2, "<usec>"),
585+
#endif
586+
#endif
587+
582588
#if !defined(CONFIG_NSH_DISABLESCRIPT) && !defined(CONFIG_NSH_DISABLE_SOURCE)
583589
CMD_MAP("source", cmd_source, 2, 2, "<script-path>"),
584590
#endif
@@ -657,10 +663,6 @@ static const struct cmdmap_s g_cmdmap[] =
657663
# endif
658664
#endif
659665

660-
#ifndef CONFIG_NSH_DISABLE_USLEEP
661-
CMD_MAP("usleep", cmd_usleep, 2, 2, "<usec>"),
662-
#endif
663-
664666
#ifndef CONFIG_NSH_DISABLE_WATCH
665667
CMD_MAP("watch", cmd_watch,
666668
2, 6, "[-n] interval [-c] count <command>"),

nshlib/nsh_proccmds.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -995,7 +995,8 @@ int cmd_pidof(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv)
995995
* Name: cmd_kill
996996
****************************************************************************/
997997

998-
#ifndef CONFIG_NSH_DISABLE_KILL
998+
#if !defined(CONFIG_NSH_DISABLE_KILL) && \
999+
!defined(CONFIG_DISABLE_ALL_SIGNALS)
9991000
int cmd_kill(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv)
10001001
{
10011002
FAR char *ptr;
@@ -1098,7 +1099,8 @@ int cmd_kill(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv)
10981099
* Name: cmd_pkill
10991100
****************************************************************************/
11001101

1101-
#if defined(CONFIG_FS_PROCFS) && !defined(CONFIG_NSH_DISABLE_PKILL)
1102+
#if defined(CONFIG_FS_PROCFS) && !defined(CONFIG_NSH_DISABLE_PKILL) && \
1103+
!defined(CONFIG_DISABLE_ALL_SIGNALS)
11021104
int cmd_pkill(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv)
11031105
{
11041106
FAR const char *name;
@@ -1199,7 +1201,8 @@ int cmd_pkill(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv)
11991201
* Name: cmd_sleep
12001202
****************************************************************************/
12011203

1202-
#ifndef CONFIG_NSH_DISABLE_SLEEP
1204+
#if !defined(CONFIG_NSH_DISABLE_SLEEP) && \
1205+
!defined(CONFIG_DISABLE_ALL_SIGNALS)
12031206
int cmd_sleep(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv)
12041207
{
12051208
UNUSED(argc);
@@ -1222,8 +1225,8 @@ int cmd_sleep(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv)
12221225
/****************************************************************************
12231226
* Name: cmd_usleep
12241227
****************************************************************************/
1225-
1226-
#ifndef CONFIG_NSH_DISABLE_USLEEP
1228+
#if !defined(CONFIG_NSH_DISABLE_USLEEP) && \
1229+
!defined(CONFIG_DISABLE_ALL_SIGNALS)
12271230
int cmd_usleep(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv)
12281231
{
12291232
UNUSED(argc);

system/sensortest/sensortest.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,10 +266,12 @@ static void usage(void)
266266
printf("\t<sensor_node_name> ex, accel0(/dev/uorb/sensor_accel0)\n");
267267
}
268268

269+
#ifdef CONFIG_ENABLE_ALL_SIGNALS
269270
static void exit_handler(int signo)
270271
{
271272
g_should_exit = true;
272273
}
274+
#endif
273275

274276
/****************************************************************************
275277
* Public Functions
@@ -300,10 +302,12 @@ int main(int argc, FAR char *argv[])
300302
return -EINVAL;
301303
}
302304

305+
#ifdef CONFIG_ENABLE_ALL_SIGNALS
303306
if (signal(SIGINT, exit_handler) == SIG_ERR)
304307
{
305308
return -errno;
306309
}
310+
#endif
307311

308312
g_should_exit = false;
309313
while ((ret = getopt(argc, argv, "i:b:n:h")) != EOF)

testing/ostest/CMakeLists.txt

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,15 @@
2222

2323
if(CONFIG_TESTING_OSTEST)
2424

25-
set(SRCS
26-
getopt.c
27-
libc_memmem.c
28-
restart.c
29-
sigprocmask.c
30-
sighand.c
31-
signest.c
32-
sighelper.c)
25+
set(SRCS getopt.c libc_memmem.c restart.c sighelper.c)
26+
27+
if(CONFIG_ENABLE_ALL_SIGNALS)
28+
list(APPEND SRCS sighand.c signest.c)
29+
endif()
30+
31+
if(NOT CONFIG_DISABLE_ALL_SIGNALS)
32+
list(APPEND SRCS sigprocmask.c)
33+
endif()
3334

3435
if(CONFIG_DEV_NULL)
3536
list(APPEND SRCS dev_null.c)

testing/ostest/Makefile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,17 @@ MODULE = $(CONFIG_TESTING_OSTEST)
3131

3232
# NuttX OS Test
3333

34-
CSRCS = getopt.c libc_memmem.c restart.c sigprocmask.c sighand.c \
34+
CSRCS = getopt.c libc_memmem.c restart.c \
3535
signest.c sighelper.c
3636

37+
ifeq ($(CONFIG_ENABLE_ALL_SIGNALS),y)
38+
CSRCS += sighand.c signest.c
39+
endif
40+
41+
ifneq ($(CONFIG_DISABLE_ALL_SIGNALS),y)
42+
CSRCS += sigprocmask.c
43+
endif
44+
3745
MAINSRC = ostest_main.c
3846

3947
ifeq ($(CONFIG_DEV_NULL),y)

testing/ostest/mqueue.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,8 +382,10 @@ void mqueue_test(void)
382382

383383
/* Wake up the receiver thread with a signal */
384384

385+
#ifndef CONFIG_DISABLE_ALL_SIGNALS
385386
printf("mqueue_test: Killing receiver\n");
386387
pthread_kill(receiver, SIGUSR1);
388+
#endif
387389

388390
/* Wait a bit to see if the thread exits on its own */
389391

wireless/ieee802154/i8sak/i8sak_events.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,13 @@ int i8sak_eventlistener_stop(FAR struct i8sak_s *i8sak)
256256
FAR void *value;
257257

258258
i8sak->eventlistener_run = false;
259+
260+
#ifndef CONFIG_DISABLE_ALL_SIGNALS
259261
pthread_kill(i8sak->eventlistener_threadid, 2);
262+
#else
263+
pthread_cancel(i8sak->eventlistener_threadid);
264+
#endif
265+
260266
ret = pthread_join(i8sak->eventlistener_threadid, &value);
261267
if (ret != OK)
262268
{

0 commit comments

Comments
 (0)