-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sys/shell: native: stop RIOT when the shell reads EOF #13675
Conversation
How about |
Sure can change it - I just wanted to be consistent with |
ok, consistency is good. edit I mean, ok to leave as is. |
There is #10788 which is also related to this (it seems, I haven't checked in details) but it provides a different approach. |
d789827
to
6d5a20d
Compare
b25d2a5
to
d33a604
Compare
d33a604
to
2992d93
Compare
BTW I don't get the same result, My shell doesn't exit but there is not loop either it just keeps printing the prompt the amount of time
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested the PR rebased on master. Please rebase!
- master:
main(): This is RIOT! (Version: 2020.07-devel-1415-gae95e-HEAD)
test_shell.
> > > > >
>
>
> > > >
>
- pr
LED_GREEN_ON
RIOT native board initialized.
RIOT native hardware initialization complete.
main(): This is RIOT! (Version: 2020.04-devel-1867-g2992d9-pr-13675)
test_shell.
>
native: exiting
make: Leaving directory '/home/francisco/workspace/RIOT/tests/shell'
On a second thought, how about we do diff --git a/sys/include/shell.h b/sys/include/shell.h
index 234fe80b35..1045325dfb 100644
--- a/sys/include/shell.h
+++ b/sys/include/shell.h
@@ -21,6 +21,7 @@
#define SHELL_H
#include <stdint.h>
+#include "periph/pm.h"
#include "kernel_defines.h"
@@ -97,7 +98,12 @@ static inline void shell_run_forever(const shell_command_t *commands,
static inline void shell_run(const shell_command_t *commands,
char *line_buf, int len)
{
+#ifdef CPU_NATIVE
+ shell_run_once(commands, line_buf, len);
+ pm_off();
+#else
shell_run_forever(commands, line_buf, len);
+#endif
}
#ifdef __cplusplus
|
2992d93
to
d9faa71
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm unable to reproduce the described behaviour locally but @aabadie gets the same behviour. Not sure where the difference comes from, but I'm OK with this temporary fix. The proper fix IMO would be to not have native shell running in cookmode
.
@benpicco feel free to squash when you add the comment.
67c2d93
to
81d08c8
Compare
@benpicco the commit you reverted is still present! |
Currently when the shell receives EOF on `native`, sending EOF (ctrl + D) closes the stdin file descriptor, leading to all consecutive reads to also return EOF. The result is that `shell_run_forever()` will re-start the shell forever in a loop, filling up the terminal with > > > > > > > > > > > > > > > > > > > > > > … until the user hits ctrl + C. This is annoying. Instead, cleanly shutdown RIOT when receiving EOF on native, which should match the expected behaviour of most users.
81d08c8
to
a6ca535
Compare
Good catch, dropped it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK.
Contribution description
Currently when the shell receives EOF on
native
, sending EOF(ctrl + D) closes the stdin file descriptor, leading to all
consecutive reads to also return EOF.
The result is that
shell_run_forever()
will re-start the shellforever in a loop, filling up the terminal with
until the user hits ctrl + C.
This is annoying.
Instead, cleanly shutdown RIOT when receiving EOF on native, which
should match the expected behaviour of most users.
Testing procedure
Run any
native
example.Press ctrl + D.
Issues/PRs references