Using pipes on Win NT 
Author Message
 Using pipes on Win NT

Hi all
I'm using open to start a batch file that does the following


echo start >> log.txt

IF EXIST startlock.txt goto EXIT

start /min notepad
echo STARTLOCK > startlock.txt

:EXIT
echo status,1
=====

While the C program that reads from that pipe executes the following
code

=====
 while(1) {
  c = getc(fp);
 }
  if( c == EOF ) return 0;    /* end of the input */
  if( c == '\n' ) break;     /* end of this line */
  if( c == ' ' && strip_space == 1 ) continue; /* ignore spaces if flag
set */
  if( i == (BUFFER_SIZE-1) ) continue; /* too big */
        /* NB!: This checl must be the last one as it changes the value
of c */
        if( c == ',' ) {
            found_comma = 1;
            c = '\0';
   *value = &buffer[i+1];
            /* if name is "exception" we dont want to strip spaces
anymore */
            if( !strncmp(buffer, "exception", i) ) {
                strip_space = 0;
            }
        }
  /* all is OK, add it to the buffer */
  buffer[i++] = c;
 }
====

If  I leave out the line that starts the notepad the above C code reads
the end of file and the loop terminates. However by issuing the "start
/min notepad" command the getc never returns AT ALL. It reads the
"status,1" and then hangs inside the getc.

Any help with this would be greatly appreciated.

Regards
Brendan Donovan



Sat, 10 May 2003 03:00:00 GMT  
 Using pipes on Win NT
Sorry that should read popen instead of open on the first line
Quote:

> Hi all
> I'm using open to start a batch file that does the following

> =====

> echo start >> log.txt

> IF EXIST startlock.txt goto EXIT

> start /min notepad
> echo STARTLOCK > startlock.txt

> :EXIT
> echo status,1
> =====

> While the C program that reads from that pipe executes the following
> code

> =====
>  while(1) {
>   c = getc(fp);
>  }
>   if( c == EOF ) return 0;    /* end of the input */
>   if( c == '\n' ) break;     /* end of this line */
>   if( c == ' ' && strip_space == 1 ) continue; /* ignore spaces if flag
> set */
>   if( i == (BUFFER_SIZE-1) ) continue; /* too big */
>         /* NB!: This checl must be the last one as it changes the value
> of c */
>         if( c == ',' ) {
>             found_comma = 1;
>             c = '\0';
>    *value = &buffer[i+1];
>             /* if name is "exception" we dont want to strip spaces
> anymore */
>             if( !strncmp(buffer, "exception", i) ) {
>                 strip_space = 0;
>             }
>         }
>   /* all is OK, add it to the buffer */
>   buffer[i++] = c;
>  }
> ====

> If  I leave out the line that starts the notepad the above C code reads
> the end of file and the loop terminates. However by issuing the "start
> /min notepad" command the getc never returns AT ALL. It reads the
> "status,1" and then hangs inside the getc.

> Any help with this would be greatly appreciated.

> Regards
> Brendan Donovan



Sat, 10 May 2003 22:43:09 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Win 2000 built OCX won't load on a WIn NT or 98 system

2. NT(Win) Services Using MAN C++

3. .DLL's for WIN NT 4.0 using Informix ESQLC

4. CGI Programming using C/C++ on Win 95/NT

5. Help: using _outp with Win NT?

6. Double Precision under Win NT using VC 5.0

7. Using _outpw Under Win NT 4.0

8. Using ExitWindowsEx to reboot Win NT

9. Double Precision under Win NT using VC 5.0

10. Problem: Developing on Win 98 and running on Win NT

11. Win NT to Win 95

12. Porting application from Win 95 to Win NT

 

 
Powered by phpBB® Forum Software