Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!batcomputer!munnari.oz.au!uunet!sdrc!thor!mustard From: mustard@thor.sdrc.com (Sandy Mustard) Newsgroups: comp.windows.x Subject: VMS XtAddInput Keywords: addinput mailboxes Message-ID: <166@thor.sdrc.com> Date: 31 May 91 19:20:17 GMT Distribution: usa Organization: SDRC, Cincinnati Lines: 252 Hi, I'm having a problem with X on VMS that I'm hoping someone out there might be able to help me with. Basically I have a process that is running as an X client. It spawns using SYS$CREPRC a subprocess (right now I'm using LOGINOUT.EXE) and assigns newly created mailboxes to it's stdin, stdout and stderr. I issue a QIO with a IO$M_WRTATTN mode and have it invoke an AST. This AST will set an event flag whenever some process writes into that mailbox. The event flag is given as the source for the XtAddInput call. The problem is that the call back specified in the XtAddInput call never gets invoked. I do see during the debugging trace that the event flag does get set. Does anyone have any experience with XtAddInput on VMS and could you enlighten me as to how I might fix this? The source code follows if this may help. #include "GlP.h" #include #include #include #include #include #include extern int crtcld(); void post_mbx_ast(); void child_term_ast(); extern FILE * act_file; extern FILE * err_file; static int next_child = 0; struct itmlst /* standard item list structure */ { short len; short code; char *buff; unsigned short *blen; }; /************************************************************************/ /* child output stream callback */ /************************************************************************/ void child_out_cb (gl_child, fdes, id) GL_CHILD *gl_child; int *fdes; int *id; { char *ptr; int stat; ptr = fgets (gl_child->out_bfr, gl_child->out_max-1, gl_child->out_file); if (ptr != NULL) { /* strip off the new line */ gl_child->out_bfr[strlen(gl_child->out_bfr)-1] = '\0'; if (gl_child->out_action != NULL) vcpu (gl_child->out_action); } else { if (gl_child->dead == FALSE) { gl_child->dead = TRUE; if (gl_child->death_action != NULL) vcpu (gl_child->death_action); } XtRemoveInput (*id); stat = SYS$DASSGN(gl_child->out_chan); } } /************************************************************************/ /* child error stream callback */ /************************************************************************/ void child_err_cb (gl_child, fdes, id) GL_CHILD *gl_child; int *fdes; int *id; { char *ptr; int stat; ptr = fgets (gl_child->err_bfr, gl_child->err_max-1, gl_child->err_file); if (ptr != NULL) { /* strip off the new line */ gl_child->err_bfr[strlen(gl_child->err_bfr)-1] = '\0'; if (gl_child->err_action != NULL) vcpu (gl_child->err_action); } else { if (gl_child->dead == FALSE) { gl_child->dead = TRUE; if (gl_child->death_action != NULL) vcpu (gl_child->death_action); } XtRemoveInput (*id); stat = SYS$DASSGN(gl_child->err_chan); } } int child_create () { int i; GL_CHILD * gl_child; int r; gl_child = child_bfr; /* for each child definition */ for (i=0; i<=child_idx; i++) { child_spawn (gl_child); /* add output handler - if requested */ if (gl_child->out_action != NULL) { r = Xt$Add_Input (&gl_child->out_file_en, 0, /* XtInputReadMask, */ child_out_cb, gl_child); } /* add error handler - if requested */ if (gl_child->err_action != NULL) { r = Xt$Add_Input (&gl_child->err_file_en, 0, /* XtInputReadMask, */ child_err_cb, gl_child); } gl_child++; } } /************************************************************************/ /* attach the child to X */ /************************************************************************/ int child_spawn (child) GL_CHILD *child; { int pid; int stat; char mbxnam[32]; struct dsc$descriptor mbxdsc; static char buffer[32]; static int buflen; static int termunit; static struct itmlst dvilst[] = { { sizeof buffer, DVI$_DEVNAM, 0-0, 0-0 }, { sizeof (long), DVI$_UNIT, &termunit, NULL }, { 0, 0, NULL, NULL } }; next_child++; sprintf(buffer, "GL_CLD%08.8d", next_child); /* create a mailbox for messages to the child */ strcpy(mbxnam, buffer); mbxnam[14] ='I'; mbxdsc.dsc$w_length = strlen(mbxnam); mbxdsc.dsc$a_pointer = mbxnam; mbxdsc.dsc$b_class = DSC$K_CLASS_S; mbxdsc.dsc$b_dtype = DSC$K_DTYPE_T; stat = SYS$CREMBX(0, &child->in_chan, BUFSIZ, BUFSIZ, 0, 0, &mbxdsc); dvilst[0].buff = buffer; dvilst[0].blen = &buflen; /* create a pipe for output messages from the child */ if (child->out_action != NULL) { mbxnam[14] ='O'; stat = SYS$CREMBX(0, &child->out_chan, BUFSIZ, BUFSIZ, 0, 0, &mbxdsc); stat = SYS$GETDVIW(0, child->out_chan, 0, dvilst, 0, 0, 0, 0); stat = LIB$GET_EF(&child->out_file_en); stat = SYS$QIO(0, child->out_chan, (IO$_SETMODE|IO$M_WRTATTN), &child->out_iosb, 0, 0, post_mbx_ast, child->out_file_en, 0, 0, 0, 0); child->out_bfr = (char *) calloc(1, child->out_max+1); child->out_file = fopen(buffer, "r"); } /* create a pipe for error messages from the child */ if (child->err_action != NULL) { mbxnam[14] ='E'; stat = SYS$CREMBX(0, &child->err_chan, BUFSIZ, BUFSIZ, 0, 0, &mbxdsc); stat = SYS$GETDVIW(0, child->err_chan, 0, dvilst, 0, 0, 0, 0); stat = LIB$GET_EF(&child->err_file_en); stat = SYS$QIO(0, child->err_chan, (IO$_SETMODE|IO$M_WRTATTN), &child->err_iosb, 0, 0, post_mbx_ast, child->err_file_en, 0, 0, 0, 0); child->err_bfr = (char *) calloc(1, child->err_max+1); child->err_file = fopen(buffer, "r"); } /* create a termination mailbox for the child */ mbxnam[14] ='T'; stat = SYS$CREMBX(0, &child->term_chan, BUFSIZ, BUFSIZ, 0, 0, &mbxdsc); stat = SYS$GETDVIW(0, child->term_chan, 0, dvilst, 0, 0, 0, 0); stat = SYS$QIO(0, child->term_chan, (IO$_SETMODE|IO$M_WRTATTN), &child->iosb, 0, 0, child_term_ast, child, 0, 0, 0, 0); fflush (act_file); /* create the child process */ if (crtcld (child->name, child->path, termunit, child->in_chan, child->out_chan, child->err_chan) == 1) { perror ("child execl"); assert (FALSE); } return(0); } void child_term_ast(child) GL_CHILD * child; { int stat; stat = SYS$QIOW(0, child->out_chan, IO$_WRITEOF, &child->iosb[0], 0, 0, 0, 0, 0, 0, 0, 0); stat = SYS$DASSGN(child->term_chan); } void post_mbx_ast(efn) int efn; { int stat; stat = SYS$SETEF(efn); }