From:	CSBVAX::MRGATE!lane@DUPHY4.Drexel.Edu@SMTP  9-MAY-1988 12:01
To:	ARISIA::EVERHART
Subj:	RE: C-servers create sys$output. sys$error.


Received: from DUPHY4.Drexel.Edu ([129.25.1.103].#Internet) by C.CS.CMU.EDU with TCP; Mon 9 May 88 10:36:51-EDT
Date:     Mon, 9 May 88 08:53:53 EDT
From:     lane (Charles Lane) @ DUPHY4.Drexel.Edu
Message-Id: <880509085338.003@DUPHY4.Drexel.Edu>
Subject:  RE: C-servers create sys$output. sys$error.
To:       REGGERS @ uwovax.UWO.CDN, cmu-tek @ DUPHY4.Drexel.Edu
cc:       lane @ DUPHY4.Drexel.Edu
Comment: Drexel University Particle Physics

> Reg Quinton <REGGERS@uwovax.UWO.CDN> writes:
>
>I have written a server in C for socket 25 (yes, my very own implementation
>of SMTP -- required since we have our very own mailer). Everytime the server
>is invoked we get a couple of spurious files
>
>        SYS$SYSTEM:SYS$ERROR. and SYS$SYSTEM:SYS$OUTPUT.
>
>Naturally these files have nothing in them since the server only talks over
>the socket... Does anyone have some ideas about how I can get my C server to
>not create these?
>

I had the same problem with a Software Tools mailer interface.  The fix
was to call as the first executable statement of the program:

            vaxcio$hack();

you need to extract, compile and link with the file included with this
message.  From the comments in the file, you can see that it was originally
part of a PostScript symbiont program!  This basically points SYS$OUTPUT
and SYS$ERROR to NL:.... you can use freopen() later if you want them
to go somewhere else.

                                --Chuck Lane    lane@duphy4.drexel.edu
                                                cel@cithex.caltech.edu

--------------- file VAXCIO$HACK.C follows, cut & extract ---------------
#include <stdio.h>
#include <ssdef.h>
#include <lnmdef.h>
#include <descrip.h>

/* for various system routines */
struct Item {
        short   size;           /* sizeof *addr */
        short   code;           /* function code */
        char*   addr;           /* item address */
        char*   rets;           /* return size */
} item0, items [3];

/* for logical names */
$DESCRIPTOR(lnm$process, "LNM$PROCESS");
$DESCRIPTOR(lnm$system, "LNM$SYSTEM");

/*
 * vaxcio$hack: Initialize vax C IO without crashing job_control
 *
 * The job_control-symbiiont interface use mailboxes to communicate.
 * In the symbiont these are sys$input and sys$output.
 * Any Vax C Unix IO function opens fd 0, 1, and 2 on the first
 * call, which writes an EOF to the mailbox on sys$output.
 * This crashes job_control. We hack around this by doing a temporary
 * `define /proc sys$output _nl:' and forcing a Vax C IO initialize.
 * We can't use lib$set_logical here, is expects a a command interpreter.
 */

vaxcio$hack()
{
        int     stat;
        struct Item * p = items;
        static $DESCRIPTOR(lognam, "SYS$OUTPUT");
        static $DESCRIPTOR(lognam2,"SYS$ERROR");
        static char * null = "_NL:";

        *p = item0;
        p->code = LNM$_STRING; p->addr = null; p->size = strlen(null); p ++;
        p->code = p->size = 0;
        stat = sys$crelnm(0, &lnm$process, &lognam, 0, &items);
        if (!(stat&1))
                sys$exit(stat);

        *p = item0;
        p->code = LNM$_STRING; p->addr = null; p->size = strlen(null); p ++;
        p->code = p->size = 0;
        stat = sys$crelnm(0, &lnm$process, &lognam2, 0, &items);
        if (!(stat&1))
                sys$exit(stat);

        write(2, "", 0);        /* calls vaxcio:initialize_io */
/*        stat = sys$dellnm(&lnm$process, &lognam, 0);
        if (!(stat&1))
                sys$exit(stat);
*/
}

------------------ end of file VAXCIO$HACK.C --------------------------
