Author Topic: problems programming a new text window for cmd.exe/4os2.exe  (Read 4643 times)

Martin Vieregg

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 120
    • View Profile
Re: problems programming a new text window for cmd.exe/4os2.exe
« Reply #90 on: February 16, 2020, 09:12:42 pm »
Yes, Laurence, you are right. It is a race between the PM editor and the helper program. DosWaitNPipe in the helper program fits the purpose:

Code: [Select]
#define logwrite if (logging) {logf = fopen (ExeDir, "at"); fprintf
#define logend; fclose (logf);}
FILE *logf;
char Inpipename[50];
    logwrite (logf, "trying opening Inpipe %s\n", Inpipename); logend;
    rc = DosOpen (Inpipename, &cmd_stdin, &ulAction, 0, FILE_NORMAL, FILE_OPEN, OPEN_ACCESS_READONLY |
                   OPEN_SHARE_DENYNONE,(PEAOP) NULL);
    if (rc != 0) {logwrite (logf, "error %i Open Named Pipe %s\n", rc, Inpipename); logend;}
    if (rc == 231) { //Pipe is busy because Server did not finished calling DosConnectNPipe yet
      Timeout = 1000;/*ms*/
      rc = DosWaitNPipe(Inpipename, Timeout);
      logwrite (logf, "DosWaitNPipe returns %i\n", rc); logend;
      //try opening pipe again
      rc = DosOpen (Inpipename, &cmd_stdin, &ulAction, 0, FILE_NORMAL, FILE_OPEN, OPEN_ACCESS_READONLY |
        OPEN_SHARE_DENYNONE,(PEAOP) NULL);
      logwrite (logf, "second trial Open Named Pipe %s returns %i\n", Inpipename, rc); logend;
    }
    else {logwrite (logf, "successful open Named Pipe %s\n", Inpipename); logend;}

I can see in the logfile, that sometimes the additional code gets executed. Now I have to implement much more easier stuff.