This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

child of fork() in TCL package DLL dumps core


WinNT Ver 4.0 build 1381 Service Pack 3

I have a TCL package that fork()s a child process, but the child process
dumps core immediately:
$ cygtclsh80 pkgfork.tcl
    0       0 [main]
E:\cygnus\cygwin-b20\H-i586-cygwin32\bin\cygtclsh80.exe 9712
handle_exceptions: Exception: STATUS_ACCESS_VIOLATION
    0    5521 [main] cygtclsh80 9712 handle_exceptions: Dumping stack
trace to cygtclsh80.exe.core

This seems to be a DLL issue because if I build the whole TCL app
staticly, everything works fine. Sample code follows:

# Makefile
CC = gcc
LDFLAGS = -ltcl80
all: pkgfork.dll
%.dll: %.o
        dllwrap --dllname $@ --def $*.def $*.o $(LDFLAGS)

# pkgfork.tcl
load pkgfork fork
fork

; pkgfork.def
EXPORTS
        Fork_Init ;

/* pkgtest.c */
#include <sys/types.h>
#include <tcl.h>

static int
cmdFork(ClientData unused, Tcl_Interp* interp, int argc, char** argv)
{
    pid_t pid;
    char buf[21];
    if (argc != 1) {
        Tcl_AppendResult(interp, "usage: ", argv[0], (char*)NULL);
        return TCL_ERROR;
    }
    switch (pid=fork()) {
        case -1:
            Tcl_SetResult(interp, "fork() failed", TCL_STATIC);
            return TCL_ERROR;
        case 0:
            exit(0);
        default:
            sprintf(buf, "%ld", pid);
            Tcl_SetResult(interp, buf, TCL_VOLATILE);
    }
    return TCL_OK;
}

int
Fork_Init(Tcl_Interp *interp)
{
    int rc = Tcl_PkgProvide(interp, "fork", "1.0");
    Tcl_CreateCommand(interp, "fork", cmdFork, NULL, NULL);
    return rc;
}
--
Paul


--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]