Tcl Source Code

Attachment Details
Login
Overview

Artifact ID: b7f0af2d3df2014a50f92f945611fbc9ad668ecc5ad5d5ff0a72d69e3512acb6
Ticket: 91c9bc1c457fda269ae18595944fc3c2b54d961d
Date: 2026-11-12 20:28:42
User: serhiy.storchaka
Artifact Attached: 2822fba342af6335650cb855068cd4c8385338db771b1271178483e04a7a2e88
Filename:repro.c
Description:
Content:
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
/* Tcl ticket 91c9bc1c45.  Windows only.  Run with stdout redirected to a
 * file:  repro.exe > out.txt  */
#include <stdio.h>
#include <io.h>
#include <fcntl.h>
#include <tcl.h>

int
main(int argc, char **argv)
{
    Tcl_Interp *interp;

    Tcl_FindExecutable(argv[0]);
    interp = Tcl_CreateInterp();
    Tcl_Eval(interp, "fconfigure stdout");	/* create the stdout channel */
    _dup2(_open("captured.txt", _O_WRONLY|_O_CREAT|_O_TRUNC, 0666), 1);
    if (Tcl_Eval(interp, "close [open repro.c]") != TCL_OK) {
	fprintf(stderr, "error: \"%s\"\n", Tcl_GetStringResult(interp));
	return 1;
    }
    fprintf(stderr, "ok\n");
    return 0;
}