After closing the bond, a spawned process can easily up and exit. Processes exit much like the way in which Expect scripts do, having a number (for instance, "exit 0“). The operating-system easily saves the dpi and a few other here is how the procedure died. This post is very helpful for non-interactive instructions but useless for interactive instructions. Consequently, it’s of little value to anticipate. Nevertheless, Expect must cope with it.
Expect must retrieve this information—even if perhaps to discard it. The action of retrieving the data frees various valuable sources (process slots) inside the computer. Until the details are retrieved, the operating-system maintains the data indefinitely. This is often seen in the creation of ps. Presuming a spawned process has died and also the connection continues to be closed, ps shows something similar to this:
PID TT STAT TIME COMMAND
4425 ? Z :00
The Z means zombie—someone’s make an effort to humorously describe a procedure that’s dead but nonetheless haunts the machine within an almost useless way. The process name and arguments happen to be discarded—no appear these were initially, they reveal up because .
To eliminate this zombie, make use of the wait command. It’s known as simply as:
Waiting for command returns a summary of elements such as the spawn id and process id. These components are further described in Chapter 14 (p. 309). For the time being, disregard the return worth of wait.
Just because a process won’t disappear in the system before you provide the wait command, it’s quite common to talk of awaiting or waiting on a procedure. Many people like to make use of the word reap as with “reaping a process”.
Because wait follows close, it’s very present with see people write "closewait" on one line. However, if the connection is closed unconditionally, waiting for must appear alone. Like close, waiting for command also occurs unconditionally. Unlike close, however, wait unconditionally occur in just one case—when an Expect process (i.e., script) exits. On exit, all of the spawned processes are anxiously waited for.
Which means that Expect scripts that just spawn just one process after which exit, do not need to call wait since it will likely be done instantly. The instance scripts to date have cheated this. Afterwards, I’ll show a script by which you should clearly wait.
One further factor about wait: Should you refer to it as before a procedure has died, your Expect script will wait for a tactic to die—hence the name. You’ll be able to steer clear of the delay using the -nowait flag.