🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.amiga.tech
Article #5126

ASyncRun() doesn't work with pipe:xxx!

#5126
From: Steve Koren
Date: Sun, 02 Sep 1990 16:46
124 lines
3903 bytes
Here's a question for all you tech types.

Why doesn't Arp's ASyncRun() call like AmigaDos pipes?

I've include a short program at the end of this note.  The program simply
runs two programs in the background.  The standard output of the
first one goes to a file named by argv[1], and the standard input of
the second one comes from a file named argv[2].  Note that the program
wants you to have certain files in ram:.

Consider this.  I run the program as:

  mytest ram:out1 ram:in1

where ram:in1 exists.  This is like saying, in Un*x:

  wc blah >out1 &
  cat <in1 &

Everything works OK.  Both programs are run
in the background.  The stdout of the first one goes to ram:out1, and
the standard input of the second one comes from ram:in1, just as
we expect.  We can run it as many times in a row as we want and
everything works: thus, the programs are being invoked correctly.

Now, lets run it again as:

  mytest pipe:a pipe:a

this is like saying:

  wc blah >pipe:a &
  cat <pipe:a &

or,

  wc blah | cat &

But IT CRASHES THE MACHINE!  Why???

Firstly, it is not a problem in the program itself.  I can create a small
program that uses ASyncRun() to invoke just one program in the background.
I run this program twice in a row, once sending output to pipe:b and
once getting input from pipe:b, and it crashes in the same way.  This
other program is very short and I am sure it is correct.

However, if I use the AmigaDos run command to invoke the programs, pipes
are handled fine.  Furthermore, if I use ASyncRun() to invoke the first
program, and run the second one in the foreground, everything is again
fine.  Even running the first with ASyncRun() and running the second
with AmigaDos run works fine.

Why doesn't ASyncRun() like to be run twice with pipe:a as output from
the first and input to the second?

Whatever this problem is, it is effectively stopping real pipes from
ever appearing in SKsh.  I will not use conman pipes, and in AmigaDos
1.3 ASyncRun() is the only practical means of executing commands in
the background.  I don't want to wait for 2.0 to get real pipes
working, but I might have to.

Anybody have a clue?

   - steve


------------------------------------------------------------------------


#include <proto/all.h>
#include <proto/Arp_Proto.h>
#include <ArpBase.h>
#include <libraries/dos.h>
#include <libraries/dosextens.h>
 
struct ArpBase *ArpBase = NULL;
 
struct ProcessControlBlock pcb;
 
long main(argc, argv)
 
   int argc;
   char *argv[];
{
   long rc = 0, stack = 4000, pri = 0;
 
   /* open arp */
   if (ArpBase == NULL)
      if ((ArpBase = (struct Arpbase *)
                     OpenLibrary("arp.library", 0L)) == NULL)
          exit(2);
 
   pcb.pcb_Input     = NULL;
   pcb.pcb_Output    = (BPTR)Open(argv[1], MODE_NEWFILE);
   pcb.pcb_StackSize = stack;
   pcb.pcb_Pri       = pri;
 
   if ((rc = ASyncRun("ram:wc", "ram:blah", &pcb)) < 0) {
      Printf("%s: unable to execute %s\n", BaseName(argv[0]), "ram:wc");
      goto Done;
   }
 
   pcb.pcb_Input     = (BPTR)Open(argv[2], MODE_OLDFILE);
   pcb.pcb_Output    = NULL;
 
   if ((rc = ASyncRun("ram:cat", "", &pcb)) < 0) {
      Printf("%s: unable to execute %s\n", BaseName(argv[0]), "ram:cat");
      goto Done;
   }
 
Done:
 
   if (rc <= 0) {
      if (pcb.pcb_Input)  Close(pcb.pcb_Input);
      if (pcb.pcb_Output) Close(pcb.pcb_Output);
   }
 
   CloseLibrary((void *)ArpBase);
 
   return(rc);
}
 
 
Technical Details
Message-ID: <13920086@hpfelg.HP.COM>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!hplabs!hpfcso!hpfelg!koren

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!hplabs!hpfcso!hpfelg!koren
From: koren@hpfelg.HP.COM (Steve Koren)
Newsgroups: comp.sys.amiga.tech
Subject: ASyncRun() doesn't work with pipe:xxx!
Message-ID: <13920086@hpfelg.HP.COM>
Date: 2 Sep 90 16:46:44 GMT
Organization: HP Elec. Design Div. -FtCollins
Lines: 124