clarkwang / sexpect

Expect for Shells
GNU General Public License v3.0
120 stars 16 forks source link

The option "-zombie-ttl N" does not work as expected #16

Closed clarkwang closed 3 years ago

clarkwang commented 3 years ago

See the following example:

$ cat zombie.sh
export SEXPECT_SOCKFILE=/tmp/zombie.$$.sock
sexpect spawn -zttl 5 sleep 10
sleep 10
sexpect wait
$ bash zombie.sh
[ERROR] connect: No such file or directory (2)
$
clarkwang commented 3 years ago

The issue is in here:

 907         /* -zombie-ttl */
 908         if (spawn->zombie_ttl >= 0 && g.SIGCHLDed && g.fd_ptm < 0 && g.conn.sock < 0) {
 909             if (Clock_diff( & spawn->startime, NULL) > spawn->zombie_ttl) {
 910                 debug("the zombie's been alive for %d seconds. killing it now.",
 911                       spawn->zombie_ttl);
 912                 break;
 913             }
 914         }

It really should not compare with spawn->startime. The semantic is also not quite correct if we compare with spawn->exittime. What we want is actually zombie idle time.

clarkwang commented 3 years ago

Will rename -zombie-ttl | -zttl to -zombie-idle | -z-idle.