hush: remove one redundant getpid() on every startup

function                                             old     new   delta
hush_main                                           1151    1147      -4

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
diff --git a/shell/hush.c b/shell/hush.c
index 3ccc181..f29c985 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -9988,6 +9988,7 @@
 int hush_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
 int hush_main(int argc, char **argv)
 {
+	pid_t cached_getpid;
 	enum {
 		OPT_login = (1 << 0),
 	};
@@ -10016,6 +10017,10 @@
 	G.argv0_for_re_execing = argv[0];
 #endif
 
+	cached_getpid = getpid();   /* for tcsetpgrp() during init */
+	G.root_pid = cached_getpid; /* for $PID   (NOMMU can override via -$HEXPID:HEXPPID:...) */
+	G.root_ppid = getppid();    /* for $$PPID (NOMMU can override)  */
+
 	/* Deal with HUSH_VERSION */
 	debug_printf_env("unsetenv '%s'\n", "HUSH_VERSION");
 	unsetenv("HUSH_VERSION"); /* in case it exists in initial env */
@@ -10103,8 +10108,6 @@
 		char *script = get_script_content(-argc - 1);
 		G.global_argv = argv;
 		G.global_argc = string_array_len(argv);
-		G.root_pid = getpid();
-		G.root_ppid = getppid();
 		//install_special_sighandlers(); - needed?
 		parse_and_run_string(script);
 		goto final_return;
@@ -10232,11 +10235,6 @@
 	G.global_argv = argv + (optind - 1);
 	G.global_argv[0] = argv[0];
 
-	if (!G.root_pid) {
-		G.root_pid = getpid();
-		G.root_ppid = getppid();
-	}
-
 	/* If we are login shell... */
 	if (flags & OPT_login) {
 		const char *hp = NULL;
@@ -10406,7 +10404,7 @@
 			 * (bash, too, does this only if ctty is available) */
 			bb_setpgrp(); /* is the same as setpgid(our_pid, our_pid); */
 			/* Grab control of the terminal */
-			tcsetpgrp(G_interactive_fd, getpid());
+			tcsetpgrp(G_interactive_fd, cached_getpid);
 		}
 		enable_restore_tty_pgrp_on_exit();