www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1999/05/07/12:50:07

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
Sender: cygwin-owner AT sourceware DOT cygnus DOT com
Delivered-To: mailing list cygwin AT sourceware DOT cygnus DOT com
Message-ID: <3733199C.F6AF88CB@swi.com>
Date: Fri, 07 May 1999 12:49:33 -0400
From: Paul Berrevoets <paul AT swi DOT com>
Organization: SWI Systemware/Halcyon Inc.
X-Mailer: Mozilla 4.51 [en] (WinNT; U)
X-Accept-Language: en
MIME-Version: 1.0
To: cygwin-list <cygwin AT sourceware DOT cygnus DOT com>
Subject: 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 AT sourceware DOT cygnus DOT com

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019