-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rm redundant getpid(2) syscalls (re: 9de6521)
Now that we have ${.sh.pid} a.k.a. shgd->current_pid, which is updated using getpid() whenever forking a new process, there is no need for anything else to ever call getpid(); we can use the stored value instead. There were a lot of these syscalls kicking around, some of them in performance-sensitive places. The following lists only changes *other* than changing getpid() to shgd->currentpid. src/cmd/ksh93/include/defs.h: - Comments: clarify what shgd->{pid,ppid,current_pid} are for. src/cmd/ksh93/sh/main.c, src/cmd/ksh93/sh/init.c: - On reinit for a new script, update shgd->{pid,ppid,current_pid} in the sh_reinit() function itself instead of calling sh_reinit() from sh_main() and then updating those immediately after that call. It just makes more sense this way. Nothing else ever calls sh_reinit() so there are no side effects. src/cmd/ksh93/sh/xec.c: _sh_fork(): - Update shgd->current_pid in the child early, so that the rest of the function can use it instead of calling getpid() again. - Remove reassignment of SH_PIDNOD->nvalue.lp value pointer to shgd->current_pid (which makes ${.sh.pid} work in the shell). It's constant and was already set on init.
Showing
13 changed files
with
43 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters