~ubuntu-branches/ubuntu/trusty/expect/trusty

« back to all changes in this revision

Viewing changes to exp_command.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Baumann
  • Date: 2006-10-01 22:23:00 UTC
  • mfrom: (2.1.7 edgy)
  • Revision ID: james.westby@ubuntu.com-20061001222300-08nd1wqc92mxggdq
Tags: 5.43.0-8
* Added patch from Niko Tyni <ntyni@iki.fi> to fix static library name on
  alpha, mips and mipsel (Closes: #390366).
* Added *.so symlink (Closes: #390365).

Show diffs side-by-side

added added

removed removed

Lines of Context:
123
123
static Tcl_HashTable slaveNames;
124
124
#endif /* HAVE_PTYTRAP */
125
125
 
126
 
/* These save the original functions so they can be used later. */
127
 
Tcl_CmdInfo exp_close_info;
128
 
Tcl_CmdInfo exp_return_info;
129
 
 
130
126
typedef struct ThreadSpecificData {
131
127
    /*
132
128
     * List of all exp channels currently open.  This is per thread and is
330
326
    /* surprised finding stdio or /dev/tty nonblocking */
331
327
    (void) Tcl_SetChannelOption(interp,esPtr->channel,"-blocking","on");
332
328
 
 
329
    /* Since we're closing the channel, not Tcl, we need to get Tcl's
 
330
       buffers flushed.  Because the channel was nonblocking, EAGAINs
 
331
       could leave things buffered.  They need to be synchronously
 
332
       written now! */
 
333
    Tcl_Flush(esPtr->channel);
 
334
 
333
335
    /*
334
336
     * Ignore close errors from ptys.  Ptys on some systems return errors for
335
337
     * no evident reason.  Anyway, receiving an error upon pty-close doesn't
1046
1048
 
1047
1049
        /* save error fd while we're setting up new one */
1048
1050
        errorfd = fcntl(2,F_DUPFD,3);
1049
 
        fcntl(3, F_SETFD, FD_CLOEXEC);
1050
1051
        /* and here is the macro to restore it */
1051
1052
#define restore_error_fd {close(2);fcntl(errorfd,F_DUPFD,2);}
1052
1053
 
1230
1231
    Tcl_DStringFree(&dstring);
1231
1232
    if (esPtr) {
1232
1233
        exp_close(interp,esPtr);
1233
 
        waitpid(esPtr->pid,&esPtr->wait,0);
 
1234
        waitpid(esPtr->pid,(int *)&esPtr->wait,0);
1234
1235
        if (esPtr->registered) {
1235
1236
            Tcl_UnregisterChannel(interp,esPtr->channel);
1236
1237
        }
2310
2311
        /* Historical note: we used "close"  long before there was a */
2311
2312
        /* Tcl builtin by the same name. */
2312
2313
 
 
2314
        Tcl_CmdInfo info;
2313
2315
        Tcl_ResetResult(interp);
2314
 
            
2315
 
        return(exp_close_info.objProc(exp_close_info.objClientData,interp,objc_orig,objv_orig));
 
2316
        if (0 == Tcl_GetCommandInfo(interp,"close",&info)) {
 
2317
            info.clientData = 0;
 
2318
        }
 
2319
        return(Tcl_CloseObjCmd(info.clientData,interp,objc_orig,objv_orig));
2316
2320
    }
2317
2321
 
2318
2322
    if (chanName) {
2578
2582
                        if (rc != TCL_OK) return(rc);
2579
2583
                    }
2580
2584
 
2581
 
                    result = waitpid(esPtr->pid,&esPtr->wait,0);
 
2585
                    result = waitpid(esPtr->pid,(int *)&esPtr->wait,0);
2582
2586
                    if (result == esPtr->pid) break;
2583
2587
                    if (result == -1) {
2584
2588
                        if (errno == EINTR) continue;
2612
2616
            for (fp=forked_proc_base;fp;fp=fp->next) {
2613
2617
                if (fp->link_status == not_in_use) continue;
2614
2618
        restart:
2615
 
                result = waitpid(fp->pid,&fp->wait_status,WNOHANG);
 
2619
                result = waitpid(fp->pid,(int *)&fp->wait_status,WNOHANG);
2616
2620
                if (result == fp->pid) {
2617
2621
                    waited_on_forked_process = 1;
2618
2622
                    break;
2957
2961
    /* if successful (i.e., TCL_RETURN is returned) */
2958
2962
    /* modify the result, so that we will handle it specially */
2959
2963
 
2960
 
    int result = exp_return_info.objProc(exp_return_info.objClientData,interp,objc,objv);
 
2964
    int result = Tcl_ReturnObjCmd(clientData,interp,objc,objv);
2961
2965
    if (result == TCL_RETURN)
2962
2966
        result = EXP_TCL_RETURN;
2963
2967
    return result;