^C doesn't interrupt cat builtin when reading from /dev/zero

Bug #1616692 reported by Elliott Hughes
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
mksh
Fix Released
Low
Thorsten Glaser

Bug Description

bash$ ./mksh
$ cat < /dev/zero > /dev/null
^C^C^C^C^C^C^C

Revision history for this message
Thorsten Glaser (mirabilos) wrote :

Please make sure you have the latest version. I recall fixing it,
and it works for me right now.

Changed in mksh:
status: New → Invalid
Revision history for this message
Thorsten Glaser (mirabilos) wrote :

Oh sorry, that was *too* fast.

With redirected stdin, this indeed breaks. Huh. Will fix, thanks for pointing it out.

Changed in mksh:
status: Invalid → Confirmed
summary: - ^C doesn't interrupt cat builtin
+ ^C doesn't interrupt cat builtin when reading from /dev/zero
Revision history for this message
Thorsten Glaser (mirabilos) wrote :

Oh, the problem appears to be that read(2) and write(2) do not
abort with EINTR if the respective devices are fast enough ☹

Please try this patch:

Index: funcs.c
===================================================================
RCS file: /cvs/src/bin/mksh/funcs.c,v
retrieving revision 1.305
diff -u -p -r1.305 funcs.c
--- funcs.c 1 Aug 2016 21:38:02 -0000 1.305
+++ funcs.c 25 Aug 2016 16:19:19 -0000
@@ -3776,12 +3776,15 @@ c_cat(const char **wp)
     /* end of file reached */
     break;
    while (n) {
+ if (intrsig)
+ goto has_intrsig;
     if ((w = write(STDOUT_FILENO, cp, n)) != -1) {
      n -= w;
      cp += w;
      continue;
     }
     if (errno == EINTR) {
+ has_intrsig:
      restore_pipe(opipe);
      /* give the user a chance to ^C out */
      intrcheck();

Changed in mksh:
assignee: nobody → Thorsten Glaser (mirabilos)
importance: Undecided → Low
status: Confirmed → Fix Committed
Revision history for this message
Elliott Hughes (enh-9) wrote :

yep, works for me on both host (ubuntu) and target (android). thanks!

Changed in mksh:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.