Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
I/O: Properly handle EIO error (Solaris patch 275-20855453)
This change is pulled from here: https://github.com/oracle/solaris-userland/blob/master/components/ksh93/patches/275-20855453.patch att#30 George Lijo wrote on 17 Feb 2017: > Here's a reproducible testcase on a Solaris11 host running > ksh93u+(2012-08-01). > $ cat a.sh > #!/bin/sh > > AAA="aaa" > echo 'insert character' > BBB=`echo ${AAA} | sed "s/aaa/bbb/g"` > logger "variable BBB = ${BBB}" > > $ cat t.sh > #!/bin/ksh > > sleep 10 > /bin/ksh ./a.sh > exit 0 > > $ > > $ ./t.sh > > The expected result is: > > Apr 9 12:43:34 lab user: [ID 702911 user.notice] variable BBB = bbb > > because variable "BBB" is supposed to be set to 'bbb' in a.sh. > > But if the parent shell is terminated, the variable is wrongly set. > > user@xxxxx$ telnet lab > ... > $ ./t.sh & <--- Run t.sh in background. > [1] 2067 > $ logout <--- CTRL + D to exit while t.sh is running. > Connection to lab closed by foreign host. > > Again, access the system and check the output: > > user@xxxxx$ telnet lab > ... > $ tail -f /var/adm/messages > : > Apr 9 12:47:47 lab user: [ID 702911 user.notice] variable BBB = > insert character <--- !!! > Apr 9 12:47:47 lab bbb > <--- !!! > > Thus the variable is wrongly set. (The previous echo string was > not cleared.) > > The issue happens because the EIO error during the logout is not > handled properly. src/cmd/ksh93/sh/io.c, src/lib/libast/include/error.h: - Amend the ERROR_PIPE() macro to check for EIO as well as EPIPE and ECONNRESET.
- Loading branch information