[Bug 281574] bc(1) runs in endless loop

From: <bugzilla-noreply_at_freebsd.org>
Date: Fri, 20 Sep 2024 16:51:20 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=281574

--- Comment #4 from John F. Carr <jfc@mit.edu> ---
I was looking in the wrong place for bc when I commented on the change history.
 Source directory usr.bin/bc is not the one that is installed.  (That one also
behaves oddly in response to ^D, probably due to the "error QUIT" rule in the
grammar not causing it to quit.)

Here is what truss says when I type ^D to an older bc, version 5.2.2 or 6.7.6:

28787: ioctl(0,TIOCSETAW,0x75c7d3a5b264)         = 0 (0x0)
28787: read(0,"\^D",1)                           = 1 (0x1)
28787: fstat(1,{ mode=crw--w---- ,inode=96,size=0,blksize=4096 }) = 0 (0x0)
28787: ioctl(1,TIOCGETA,0x4c2f87f0125c)          = 0 (0x0)
28787: write(1,"^D",2)                           = 2 (0x2)
28787: ioctl(0,TIOCSETAW,0x75c7d3a5b238)         = 0 (0x0)
28787: write(1,"\n",1)                           = 1 (0x1)
28787: ioctl(0,TIOCSETAF,0x75c7d3a5b20c)         = 0 (0x0)
28787: exit(0x0)

All is well despite the odd behavior of a literal ^D being read.

If I have 7.0.1 then it does not quit and truss says

37822: ioctl(0,TIOCSETAW,0x88d4efe5b264)         = 0 (0x0)
37822: read(0,"\^D",1)                           = 1 (0x1)
37822: fstat(1,{ mode=crw------- ,inode=45,size=0,blksize=4096 }) = 0 (0x0)
37822: ioctl(1,TIOCGETA,0x7ddad4152e7c)          = 0 (0x0)
37822: write(1,"^D",2)                           = 2 (0x2)
37822: ioctl(0,TIOCSETAW,0x88d4efe5b238)         = 0 (0x0)
37822: sigprocmask(SIG_BLOCK,{ SIGWINCH },{ })   = 0 (0x0)
37822: ioctl(0,TIOCGWINSZ,0x7ddad4153100)        = 0 (0x0)
37822: sigprocmask(SIG_SETMASK,{ },0x0)          = 0 (0x0)
37822: ioctl(0,TIOCGETA,0x88d4efe5b290)          = 0 (0x0)
37822: ioctl(0,TIOCSETAW,0x88d4efe5b264)

-- 
You are receiving this mail because:
You are the assignee for the bug.