native: allow for native to be resetable via SIGUSR1#12517
native: allow for native to be resetable via SIGUSR1#12517miri64 merged 2 commits intoRIOT-OS:masterfrom
Conversation
40129dc to
943fd68
Compare
|
Test, works as advertised. |
|
on FreeBSD I get: |
cpu/native/startup.c
Outdated
|
|
||
| /* should not error as SIGUSR is a valid error code and EINVAL is the only | ||
| * specified error code => don't check return value */ | ||
| signal(SIGUSR1, reset_handler); |
There was a problem hiding this comment.
I think you need to (should) use: https://github.com/RIOT-OS/RIOT/blob/master/cpu/native/irq_cpu.c#L412 instead
cpu/native/startup.c
Outdated
| extern init_func_t __init_array_end; | ||
| #endif | ||
|
|
||
| static void reset_handler(int signo) |
There was a problem hiding this comment.
I changed this to
static void _reset_handler(void)
{
pm_reboot();
}
and added:
register_interrupt(SIGUSR1, _reset_handler);
below and it works on FreeBSD, the signal(...) is not needed
|
with the proposed changes it looks good: |
|
I will apply the changes @smlng proposed and retest on Linux. |
cpu/native/include/native_internal.h
Outdated
| * | ||
| * @see e.g. https://www.freebsd.org/cgi/man.cgi?query=signal§ion=3 | ||
| */ | ||
| typedef void (*real_sig_t) (int); |
There was a problem hiding this comment.
Oh yeah, sorry.... still on my first coffee ^^"
cpu/native/include/native_internal.h
Outdated
| *__restrict value, struct itimerval *__restrict ovalue); | ||
| extern int (*real_setsid)(void); | ||
| extern int (*real_setsockopt)(int socket, ...); | ||
| extern real_sig_t (*real_signal)(int sig, real_sig_t handler); |
cpu/native/syscalls.c
Outdated
| *restrict value, struct itimerval *restrict ovalue); | ||
| int (*real_setsid)(void); | ||
| int (*real_setsockopt)(int socket, ...); | ||
| real_sig_t (*real_signal)(int sig, real_sig_t handler); |
|
when done, please squash and trigger Murdock please |
|
Cleaned out now unnecessary changes and squashed. |
a2ce01d to
d670f77
Compare
I guess FreeBSD implies OSX? |
|
RIOT does not work on latest macOS, bc the latter is 64bit only now - so no macOS right now |
@x3ro are you still working on a 64-bit native port? (: |
There is I think twenty years of divergence between FreeBSD and Darwin ^^, but okay :-) |
Contribution description
Based on the discussion sparked by this comment #12448 (comment) I decided to provide a simple PoC of how to make
nativeresetable.Testing procedure
Start a
nativeinstance in one terminal (application is arbitrary), find out its PID in another terminal, and then use the PID to reset e.g.:The
nativeinstance should then reboot (noticeable by a big fat!! REBOOT !!printed)Issues/PRs references
#12448 (comment)