diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-02-27 18:28:49 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-02-27 18:28:49 +0000 |
commit | 0582f98ab57d15e55717a22ba4bba6d961c3395b (patch) | |
tree | 1229f23dad461ada1da50788350804fbf8039956 /nuttx/examples/nsh/nsh_fscmds.c | |
parent | e1920b37dfc358ae73ce55665b36877c99db4e5b (diff) | |
download | nuttx-0582f98ab57d15e55717a22ba4bba6d961c3395b.tar.gz nuttx-0582f98ab57d15e55717a22ba4bba6d961c3395b.tar.bz2 nuttx-0582f98ab57d15e55717a22ba4bba6d961c3395b.zip |
cat and cp need to exit if a signal is recievednuttx-5.18
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3323 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/examples/nsh/nsh_fscmds.c')
-rw-r--r-- | nuttx/examples/nsh/nsh_fscmds.c | 63 |
1 files changed, 49 insertions, 14 deletions
diff --git a/nuttx/examples/nsh/nsh_fscmds.c b/nuttx/examples/nsh/nsh_fscmds.c index cdc4ac0cd..eb43ed23c 100644 --- a/nuttx/examples/nsh/nsh_fscmds.c +++ b/nuttx/examples/nsh/nsh_fscmds.c @@ -432,14 +432,21 @@ int cmd_cat(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) if (nbytesread < 0) { - /* EINTR is not an error */ + /* EINTR is not an error (but will stop stop the cat) */ - if (errno != EINTR) +#ifndef CONFIG_DISABLE_SIGNALS + if (errno == EINTR) + { + nsh_output(vtbl, g_fmtsignalrecvd, argv[0]); + } + else +#endif { nsh_output(vtbl, g_fmtcmdfailed, argv[0], "read", NSH_ERRNO); - ret = ERROR; - break; } + + ret = ERROR; + break; } /* Check for data successfully read */ @@ -453,14 +460,20 @@ int cmd_cat(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) int n = write(1, buffer, nbytesread); if (n < 0) { - /* EINTR is not an error */ + /* EINTR is not an error (but will stop stop the cat) */ - if (errno != EINTR) + #ifndef CONFIG_DISABLE_SIGNALS + if (errno == EINTR) + { + nsh_output(vtbl, g_fmtsignalrecvd, argv[0]); + } + else +#endif { nsh_output(vtbl, g_fmtcmdfailed, argv[0], "write", NSH_ERRNO); - ret = ERROR; - break; } + ret = ERROR; + break; } else { @@ -593,11 +606,22 @@ int cmd_cp(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) ret = OK; goto errout_with_wrfd; } - else if (nbytesread < 0 && errno != EINTR) + else if (nbytesread < 0) { - /* Read error */ + /* EINTR is not an error (but will still stop the copy) */ - nsh_output(vtbl, g_fmtcmdfailed, argv[0], "read", NSH_ERRNO); +#ifndef CONFIG_DISABLE_SIGNALS + if (errno == EINTR) + { + nsh_output(vtbl, g_fmtsignalrecvd, argv[0]); + } + else +#endif + { + /* Read error */ + + nsh_output(vtbl, g_fmtcmdfailed, argv[0], "read", NSH_ERRNO); + } goto errout_with_wrfd; } } @@ -610,11 +634,22 @@ int cmd_cp(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) { nbytesread -= nbyteswritten; } - else if (errno != EINTR) + else { - /* Read error */ + /* EINTR is not an error (but will still stop the copy) */ + +#ifndef CONFIG_DISABLE_SIGNALS + if (errno == EINTR) + { + nsh_output(vtbl, g_fmtsignalrecvd, argv[0]); + } + else +#endif + { + /* Read error */ - nsh_output(vtbl, g_fmtcmdfailed, argv[0], "write", NSH_ERRNO); + nsh_output(vtbl, g_fmtcmdfailed, argv[0], "write", NSH_ERRNO); + } goto errout_with_wrfd; } } |