delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2003/02/24/18:43:07

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
From: james DOT m DOT barker AT boeing DOT com
Subject: mknod implementation clarification...thanks for the help
To: cygwin AT cygwin DOT com
Date: Mon, 24 Feb 2003 15:13:55 -0800
Message-ID: <OF4DA3607F.ADF7DB7B-ON88256CD7.007EB820@hughes.com>
MIME-Version: 1.0

Here's the sample code that calls mknod.  I always do a bad job of
explaining in words what I'm trying to accomplish.
Hopefully the sample code does a better job of it.  I'm glad to hear that plans are in the work to include this
capability.

A series of "write" commands are made to gvFD to communicate with geomview.

Thanks again

Jim Barker

int GVdriver::StartGeomview()
{
     pipename = new char[40];
     sprintf(pipename,"/tmp/geomview/GVU%0iP%0i",getuid(),getpid());

     char *args[5];
     args[0] = "geomview";
     args[1] = "-Mcp";
     args[2] = pipename;
     args[3] = "-nopanels";
     args[4] = NULL;
     gvFD=-1;
     #ifndef __GNUC__
     if(access("/tmp/geomview",W_ACC) <0) {
     #else
     if(access("/tmp/geomview",W_OK) <0) {
     #endif
          mkdir("/tmp/geomview",0777);
          chmod("/tmp/geomview",0777);  //sometimes mkdir doesn't work!?
          }
     #ifndef __GNUC__
     if(access(pipename,E_ACC)<0) {
     #else
     if(access(pipename,F_OK)<0) {
     #endif
          mknod(pipename, S_IFIFO | 0660 , 0);
          }

     gvFD = open(pipename, O_WRONLY | O_NONBLOCK);
     if(gvFD >= 0) {
          #ifndef __GNUC__
          fcntl(gvFD, F_SETFL, fcntl(gvFD, F_GETFL, 0) & ~(FNDELAY|FNONBLOCK|O_NONBLOCK));
          #else
          fcntl(gvFD, F_SETFL, fcntl(gvFD, F_GETFL, 0) & ~(FNDELAY|FNONBIO|O_NONBLOCK));
          #endif
     } else if(errno == ENXIO) {
          gvPID=fork();
          if(gvPID==0) {
               close(0);
               #ifndef __GNUC__
               setpgrp(0,0);
               #else
               setpgrp();
               #endif
               execvp("geomview",args);
               perror("couldn't start geomview");
               kill(getppid(), SIGALRM);
               _exit(1);
               }

          alarm(60);
          gvFD = open(pipename, O_WRONLY);
          alarm(0);
          unlink(pipename);

          }

     if(gvFD<0) {
          fprintf(stderr,"Gotta give up trying to pipe to geomview: ");
          perror(pipename);
          }


     return 0;
     }



--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


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