1

This question already has an answer here:

I'm working on a retro project and was trying to create a pipe of stdin/out/err in DOS, but I can't find any functions to to this?

For instance the pipe() command from unistd.h isn't present in BorlandC, which I'm using.

Can anyone tell me how to to this? Preferably in C or Batch.

Also, how to pipe stdin/out from the current shell (command.com or 4dos.com) in order to "Skin" the console?

[edit] Awnser from retrocomputing

https://retrocomputing.stackexchange.com/questions/9609/dos-create-pipe-for-stdin-stdout-of-command-comor-4dos-com-in-c-or-batch

marked as duplicate by Martin Rosenau, Ross Ridge, Raffzahn, JAL, mschaef Apr 8 at 20:58

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

migrated from stackoverflow.com Apr 8 at 18:41

This question came from our site for professional and enthusiast programmers.

  • I'm migrating this to Retro-computing, please ask the moderators there to merge this post with your other post. – Bhargav Rao Apr 8 at 18:41
  • @BhargavRao The user already asked the same question on Retro-computing Stackexchange. Therefore I voted to close it. – Martin Rosenau Apr 8 at 18:51
3

DOS is a single-tasking OS. What this means is that it's designed under the assumption that there's only ever one process running.

If there's only ever one process running, then it's impossible for another process to be at the other end of a pipe at the time, so pipes don't really make any sense.

For this reason DOS just has minimal "fake pipes" for stdin/stdout. Originally (DOS 1.0) these were just synonyms for console input/output (and could never be redirected to files). Later (DOS 2.0) they added the ability to redirect stdin/stdout to a file in the command interpreter (command.com); but it's still not real pipes (there's no support for changing stdin/stdout after a program has started, no way to create other pipes, no way to close stdin/stdout, etc). Also, stderr doesn't exist at all - a program (or a C standard library) would emulate it with a "direct console output" function (in case stdout is being redirected).

-1

There is no point refeering questions like this to Retro Computing. The answer remains the same over decades, the beauty of Windows.

GetStdHandle is the function call that has worked for at least 19 years and probably 26.

See https://docs.microsoft.com/en-us/windows/console/getstdhandle

Retrieves a handle to the specified standard device (standard input, standard output, or standard error).

HANDLE WINAPI GetStdHandle(
  _In_ DWORD nStdHandle
);

Your question is unclear. Command.com does piping, not programs. In Dos you can read/write std handles using Int21. See http://spike.scu.edu.au/~barry/interrupts.html

AH = 02h -WRITE CHARACTER TO STANDARD OUTPUT

Entry: DL = character to write

Return: AL = last character output

Notes: •^C/^Break are checked •the last character output will be the character in DL unless DL=09h on entry, in which case AL=20h as tabs are expanded to blanks •if standard output is redirected to a file, no error checks (write- protected, full media, etc.) are performed

SeeAlso: AH=06h,AH=09h

This is all documented in MS compilers of the time. I'm sure Borland documented too.

  • 1
    This is windows. What I'm asking for is actual DOS. – Dacobi Apr 7 at 10:38
  • The background of this question seems to be that the User wants to write a program similar to the Linux program "xterm" for (the old 16-bit) MS-DOS. This would however require a multi-tasking OS but MS-DOS is a single-tasking OS. – Martin Rosenau Apr 8 at 18:49

Not the answer you're looking for? Browse other questions tagged or ask your own question.