CARVIEW |
Select Language
HTTP/2 200
date: Sun, 27 Jul 2025 19:48:31 GMT
content-type: text/html; charset=utf-8
vary: X-PJAX, X-PJAX-Container, Turbo-Visit, Turbo-Frame, X-Requested-With,Accept-Encoding, Accept, X-Requested-With
x-repository-download: git clone https://github.com/ksh93/ksh.git
etag: W/"f68a797ba50aba537007abf1ae3c8e2d"
cache-control: max-age=0, private, must-revalidate
strict-transport-security: max-age=31536000; includeSubdomains; preload
x-frame-options: deny
x-content-type-options: nosniff
x-xss-protection: 0
referrer-policy: no-referrer-when-downgrade
content-security-policy: default-src 'none'; base-uri 'self'; child-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/; connect-src 'self' uploads.github.com www.githubstatus.com collector.github.com raw.githubusercontent.com api.github.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com *.rel.tunnels.api.visualstudio.com wss://*.rel.tunnels.api.visualstudio.com objects-origin.githubusercontent.com copilot-proxy.githubusercontent.com proxy.individual.githubcopilot.com proxy.business.githubcopilot.com proxy.enterprise.githubcopilot.com *.actions.githubusercontent.com wss://*.actions.githubusercontent.com productionresultssa0.blob.core.windows.net/ productionresultssa1.blob.core.windows.net/ productionresultssa2.blob.core.windows.net/ productionresultssa3.blob.core.windows.net/ productionresultssa4.blob.core.windows.net/ productionresultssa5.blob.core.windows.net/ productionresultssa6.blob.core.windows.net/ productionresultssa7.blob.core.windows.net/ productionresultssa8.blob.core.windows.net/ productionresultssa9.blob.core.windows.net/ productionresultssa10.blob.core.windows.net/ productionresultssa11.blob.core.windows.net/ productionresultssa12.blob.core.windows.net/ productionresultssa13.blob.core.windows.net/ productionresultssa14.blob.core.windows.net/ productionresultssa15.blob.core.windows.net/ productionresultssa16.blob.core.windows.net/ productionresultssa17.blob.core.windows.net/ productionresultssa18.blob.core.windows.net/ productionresultssa19.blob.core.windows.net/ github-production-repository-image-32fea6.s3.amazonaws.com github-production-release-asset-2e65be.s3.amazonaws.com insights.github.com wss://alive.github.com api.githubcopilot.com api.individual.githubcopilot.com api.business.githubcopilot.com api.enterprise.githubcopilot.com; font-src github.githubassets.com; form-action 'self' github.com gist.github.com copilot-workspace.githubnext.com objects-origin.githubusercontent.com; frame-ancestors 'none'; frame-src viewscreen.githubusercontent.com notebooks.githubusercontent.com; img-src 'self' data: blob: github.githubassets.com media.githubusercontent.com camo.githubusercontent.com identicons.github.com avatars.githubusercontent.com private-avatars.githubusercontent.com github-cloud.s3.amazonaws.com objects.githubusercontent.com release-assets.githubusercontent.com secured-user-images.githubusercontent.com/ user-images.githubusercontent.com/ private-user-images.githubusercontent.com opengraph.githubassets.com copilotprodattachments.blob.core.windows.net/github-production-copilot-attachments/ github-production-user-asset-6210df.s3.amazonaws.com customer-stories-feed.github.com spotlights-feed.github.com objects-origin.githubusercontent.com *.githubusercontent.com; manifest-src 'self'; media-src github.com user-images.githubusercontent.com/ secured-user-images.githubusercontent.com/ private-user-images.githubusercontent.com github-production-user-asset-6210df.s3.amazonaws.com gist.github.com; script-src github.githubassets.com; style-src 'unsafe-inline' github.githubassets.com; upgrade-insecure-requests; worker-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/
server: github.com
content-encoding: gzip
accept-ranges: bytes
set-cookie: _gh_sess=6faDBesc5M3N8M0QxdCo98b0w6KkplIWj9g0wV%2Byh7MOBLOR3PVd8FgmMuP5mBgPIQm0x00Ir8k53NEPRNcPm0uQ8S6jMZD%2BMEqWv1v64uoUvKEFlBk85S1dfGnqOPBQQJKEjra7HlVm8jTXKna1yPqYqYC%2F6X16Yfv4o%2Bat4iveFGlq7bQIfUbLIIh4txe%2B0hCk92f4d6iKQa8QAUdkB3oDNvVWgEbk3vKIvxHJMXfgYqiG7XClIPA7k24TvmZGaS5XNij%2BAcquEauaCjtrKw%3D%3D--afOH1SNX5UJImX8M--6lAmOl8KUNX5kKOtEfv1hw%3D%3D; Path=/; HttpOnly; Secure; SameSite=Lax
set-cookie: _octo=GH1.1.2014955975.1753645710; Path=/; Domain=github.com; Expires=Mon, 27 Jul 2026 19:48:30 GMT; Secure; SameSite=Lax
set-cookie: logged_in=no; Path=/; Domain=github.com; Expires=Mon, 27 Jul 2026 19:48:30 GMT; HttpOnly; Secure; SameSite=Lax
x-github-request-id: 8B0E:21EF6:7DAC47:A4D738:6886828E
Fix the exec optimisation mess (re: 17ebfbf6, 6701bb30, f0b0b67d) · ksh93/ksh@88aa369 · GitHub
Copy file name to clipboardExpand all lines: src/cmd/ksh93/bltins/trap.c
Copy file name to clipboardExpand all lines: src/cmd/ksh93/include/shell.h
Copy file name to clipboardExpand all lines: src/cmd/ksh93/tests/basic.sh
Skip to content
Navigation Menu
{{ message }}
-
Notifications
You must be signed in to change notification settings - Fork 36
Commit 88aa369
committed
This commit supersedes @lijog's Solaris patch 280-23332860 (see
17ebfbf) as this is a more general fix that makes the patch
redundant. Of course its associated regression tests stay.
Reproducer script:
trap 'echo SIGUSR1 received' USR1
sh -c 'kill -s USR1 $PPID'
Run as a normal script.
Expected behaviour: prints "SIGUSR1 received"
Actual behaviour: the shell invoking the script terminates. Oops.
As of 6701bb3, ksh again allows an exec-without-fork optimisation
for the last command in a script. So the 'sh' command gets the same
PID as the script, therefore its parent PID ($PPID) is the invoking
script and not the script itself, which has been overwritten in
working memory. This shows that, if there are traps set, the exec
optimisation is incorrect as the expected process is not signalled.
While 6701bb3 reintroduced this problem for scripts, this has
always been an issue for certain other situations: forked command
substitutions, background subshells, and -c option argument
scripts. This commit fixes it in all those cases.
In sh_exec(), case TFORK, the optimisation (flagged in no_fork) was
only blocked for SIGINT and for the EXIT and ERR pseudosignals.
That is wrong. It should be blocked for all signal and pseudosignal
traps, except DEBUG (which is run before the command) and SIGKILL
and SIGSTOP (which cannot be trapped).
(I've also tested the behaviour of other shells. One shell, mksh,
never does an exec optimisation, even if no traps are set. I don't
know if that is intentional or not. I suppose it is possible that a
script might expect to receive a signal without trapping it first,
and they could conceivably be affected the same way by this exec
optimisation. But the ash variants (e.g. Busybox ash, dash, FreeBSD
sh), as well as bash, yash and zsh, all do act like this, so the
behaviour is very widespread. This commit makes ksh act like them.)
Multiple files:
- Remove the sh.errtrap, sh.exittrap and sh.end_fn flags and their
associated code from the superseded Solaris patch.
src/cmd/ksh93/include/shell.h:
- Add a scoped sh.st.trapdontexec flag for sh_exec() to disable
exec-without-fork optimisations. It should be in the sh.st scope
struct because it needs to be reset in subshell scopes.
src/cmd/ksh93/bltins/trap.c: b_trap():
- Set sh.st.trapdontexec if any trap is set and non-empty (an empty
trap means ignore the signal, which is inherited by an exec'd
process, so the optimisation is fine in that case).
- Only clear sh.st.trapdontexec if we're not in a ksh function
scope; unlike subshells, ksh functions fall back to parent traps
if they don't trap a signal themselves, so a ksh function's
parent traps also need to disable the exec optimisation.
src/cmd/ksh93/sh/fault.c: sh_sigreset():
- Introduce a new -1 mode for sh_funscope() to use, which acts like
mode 0 except it does not clear sh.st.trapdontexec. This avoids
clearing sh.st.trapdontexec for ksh functions scopes (see above).
- Otherwise, clear sh.st.trapdontexec whenever traps are reset.
src/cmd/ksh93/sh/xec.c: check_exec_optimization():
- Consolidate all the exec optimisation logic into this function,
including the logic from the no_fork flag in sh_exec()/TFORK.
- In the former no_fork flag logic, replace the three checks for
SIGINT, ERR and EXIT traps with a single check for the
sh.st.trapdontexec flag.
1 parent f0b0b67 commit 88aa369Copy full SHA for 88aa369
Expand file treeCollapse file tree
8 files changed
+123
-43
lines changed+4Lines changed: 4 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
10 | 10 |
| |
11 | 11 |
| |
12 | 12 |
| |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
13 | 17 |
| |
14 | 18 |
| |
15 | 19 |
| |
|
src/cmd/ksh93/bltins/trap.c
Copy file name to clipboardExpand all lines: src/cmd/ksh93/bltins/trap.c+33-11Lines changed: 33 additions & 11 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
136 | 136 |
| |
137 | 137 |
| |
138 | 138 |
| |
139 |
| - | |
140 |
| - | |
141 |
| - | |
142 |
| - | |
143 |
| - | |
144 |
| - | |
145 |
| - | |
146 | 139 |
| |
147 | 140 |
| |
148 | 141 |
| |
| |||
159 | 152 |
| |
160 | 153 |
| |
161 | 154 |
| |
162 |
| - | |
163 |
| - | |
164 | 155 |
| |
165 | 156 |
| |
166 | 157 |
| |
| |||
180 | 171 |
| |
181 | 172 |
| |
182 | 173 |
| |
183 |
| - | |
184 |
| - | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
185 | 207 |
| |
186 | 208 |
| |
187 | 209 |
| |
|
src/cmd/ksh93/include/shell.h
Copy file name to clipboardExpand all lines: src/cmd/ksh93/include/shell.h+3-5Lines changed: 3 additions & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
204 | 204 |
| |
205 | 205 |
| |
206 | 206 |
| |
| 207 | + | |
207 | 208 |
| |
208 | 209 |
| |
209 | 210 |
| |
| |||
335 | 336 |
| |
336 | 337 |
| |
337 | 338 |
| |
338 |
| - | |
| 339 | + | |
339 | 340 |
| |
340 |
| - | |
| 341 | + | |
341 | 342 |
| |
342 | 343 |
| |
343 | 344 |
| |
| |||
381 | 382 |
| |
382 | 383 |
| |
383 | 384 |
| |
384 |
| - | |
385 |
| - | |
386 |
| - | |
387 | 385 |
| |
388 | 386 |
| |
389 | 387 |
| |
|
+6Lines changed: 6 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
315 | 315 |
| |
316 | 316 |
| |
317 | 317 |
| |
| 318 | + | |
318 | 319 |
| |
319 | 320 |
| |
320 | 321 |
| |
321 | 322 |
| |
322 | 323 |
| |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
323 | 329 |
| |
324 | 330 |
| |
325 | 331 |
| |
|
-6Lines changed: 0 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1527 | 1527 |
| |
1528 | 1528 |
| |
1529 | 1529 |
| |
1530 |
| - | |
1531 |
| - | |
1532 |
| - | |
1533 | 1530 |
| |
1534 | 1531 |
| |
1535 | 1532 |
| |
| |||
1714 | 1711 |
| |
1715 | 1712 |
| |
1716 | 1713 |
| |
1717 |
| - | |
1718 |
| - | |
1719 |
| - | |
1720 | 1714 |
| |
1721 | 1715 |
| |
1722 | 1716 |
| |
|
-3Lines changed: 0 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
467 | 467 |
| |
468 | 468 |
| |
469 | 469 |
| |
470 |
| - | |
471 |
| - | |
472 |
| - | |
473 | 470 |
| |
474 | 471 |
| |
475 | 472 |
| |
|
+13-17Lines changed: 13 additions & 17 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
909 | 909 |
| |
910 | 910 |
| |
911 | 911 |
| |
912 |
| - | |
| 912 | + | |
913 | 913 |
| |
914 |
| - | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
915 | 921 |
| |
| 922 | + | |
916 | 923 |
| |
917 | 924 |
| |
918 | 925 |
| |
| |||
1133 | 1140 |
| |
1134 | 1141 |
| |
1135 | 1142 |
| |
1136 |
| - | |
| 1143 | + | |
1137 | 1144 |
| |
1138 | 1145 |
| |
1139 | 1146 |
| |
| |||
1506 | 1513 |
| |
1507 | 1514 |
| |
1508 | 1515 |
| |
1509 |
| - | |
1510 |
| - | |
1511 |
| - | |
1512 |
| - | |
1513 |
| - | |
1514 |
| - | |
1515 |
| - | |
1516 |
| - | |
1517 |
| - | |
| 1516 | + | |
1518 | 1517 |
| |
1519 | 1518 |
| |
1520 | 1519 |
| |
| |||
1799 | 1798 |
| |
1800 | 1799 |
| |
1801 | 1800 |
| |
1802 |
| - | |
| 1801 | + | |
1803 | 1802 |
| |
1804 | 1803 |
| |
1805 | 1804 |
| |
| |||
3100 | 3099 |
| |
3101 | 3100 |
| |
3102 | 3101 |
| |
3103 |
| - | |
| 3102 | + | |
3104 | 3103 |
| |
3105 | 3104 |
| |
3106 | 3105 |
| |
| |||
3117 | 3116 |
| |
3118 | 3117 |
| |
3119 | 3118 |
| |
3120 |
| - | |
3121 |
| - | |
3122 | 3119 |
| |
3123 | 3120 |
| |
3124 | 3121 |
| |
| |||
3169 | 3166 |
| |
3170 | 3167 |
| |
3171 | 3168 |
| |
3172 |
| - | |
3173 | 3169 |
| |
3174 | 3170 |
| |
3175 | 3171 |
| |
|
src/cmd/ksh93/tests/basic.sh
Copy file name to clipboardExpand all lines: src/cmd/ksh93/tests/basic.sh+64-1Lines changed: 64 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
928 | 928 |
| |
929 | 929 |
| |
930 | 930 |
| |
| 931 | + | |
| 932 | + | |
931 | 933 |
| |
932 |
| - | |
| 934 | + | |
933 | 935 |
| |
934 | 936 |
| |
935 | 937 |
| |
936 | 938 |
| |
937 | 939 |
| |
938 | 940 |
| |
939 | 941 |
| |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
940 | 1003 |
| |
941 | 1004 |
|
You can’t perform that action at this time.
0 commit comments