Hi!

16-Сен-2006 02:29 [EMAIL PROTECTED] (Blair Campbell) wrote to
freedos-user@lists.sourceforge.net:

BC> Hi.  It almost sounds to me like the destination file isn't getting
BC> flushed to the disk.  I would recommend doing the recirection
BC> internally in the C program, and then you have direct control of the
BC> file.  A simple close(1); open("blah", O_WRONLY); /* system() stuff
BC> here: */ blah blah blah close(1); open("CON", O_WRONLY);
BC> should do but there are also ways to 'save' the original stdout and
BC> restore it later.  Get him to contact me for details.
>> BUT, if I do it this way:
>> command /c dir /b c:\testdir >d:\dirout.put
>> The file dirout.put has the directory output but CUT... it never
>> reaches the end of the output, it just cuts...

     This is bug in FreeCOM. And this is reason, why in my patches for
FreeCOM I was tried to move command.com placement into bin/ subdirectory,
else (buggy) command.com (may) interfere with building process, but by some
unknown reason you reject this part of patches.

     About manual redirecting: using open("CON") is wrong, because this
prevents using program with redirection. The more so, if program uses
stdio..h, this way is even more wrong. I think, better way is something
like:

int redirfd = open ("d:\dirout.put", O_CREAT | O_TRUNC | O_RDWR,
                                     S_IREAD | S_IWRITE);
if (redirfd != -1) { /* check for error */
  /* if using standard streams from stdio.h: */
  flushall (); /* flush all high level buffers */
  /* now privately store own stdout... */
  int oldstdout = dup (1);
  /* ...and open redirection */
  dup2 (redirfd, 1); close (redirfd);

  ...now do system(), spwan*() or exec*()...

  dup2 (oldstdout, 1); close (oldstdout);
}

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Freedos-user mailing list
Freedos-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-user

Reply via email to