Code:
$ truss -fp ksh -c 'while read l
do
lsum=$(( $lsum + $l))
done <<! ; echo $? ; echo $lsum
1
2
3
!
'
[22593] execve("/usr/bin/ksh", 0x7b0f11a4, 0x7b0f11b4) ... = 0 [32-bit]
.
.
.
[22593] open("/tmp/sh22593.1", O_RDWR|O_CREAT|O_EXCL, 0600) = 3
[22593] write(3, "1 \n2 \n3 \n", 6) ...................... = 6
[22593] close(3) ......................................... = 0
[22593] fcntl(0, F_DUPFD, 10) ............................ = 10
[22593] fcntl(10, F_GETFD, 0) ............................ = 0
[22593] fcntl(10, F_SETFD, 1) ............................ = 0
[22593] open("/tmp/sh22593.1", O_RDONLY|O_LARGEFILE, 01) . = 3
[22593] fcntl(0, F_GETFD, 0) ............................. = 0
[22593] close(0) ......................................... = 0
[22593] fcntl(3, F_DUPFD, 0) ............................. = 0
[22593] close(3) ......................................... = 0
[22593] sigprocmask(SIG_BLOCK, 0x7b0f2c20, 0x7b0f2c00) ... = 0
[22593] sigprocmask(SIG_SETMASK, 0x7b0f2c00, NULL) ....... = 0
[22593] fcntl(0, F_GETFL, 0) ............................. = 2048
[22593] lseek(0, 0, SEEK_CUR) ............................ = 0
[22593] ioctl(0, TCGETATTR, 0x40004b90) .................. ERR#25 ENOTTY
[22593] sigprocmask(SIG_BLOCK, 0x7b0f2b60, 0x7b0f2b40) ... = 0
[22593] read(0, "1 \n2 \n3 \n", 1024) .................... = 6
.
.
.
[22593] read(0, 0x400059b0, 1024) ........................ = 0
.
.
.
[22593] fcntl(0, F_GETFD, 0) ............................. = 0
[22593] close(0) ......................................... = 0
[22593] fcntl(10, F_DUPFD, 0) ............................ = 0
[22593] close(10) ........................................ = 0
[22593] fcntl(0, F_SETFD, 0) ............................. = 0
[22593] unlink("/tmp/sh22593.1") ......................... = 0
[22593] sigprocmask(SIG_BLOCK, 0x7b0f15a0, 0x7b0f1580) ... = 0
[22593] sigprocmask(SIG_SETMASK, 0x7b0f1580, NULL) ....... = 0
0
6
[22593] write(1, "0 \n6 \n", 4) .......................... = 4
[22593] exit(0) .......................................... WIFEXITED(0)
$