Some Wizardry in need

Suresh Subramanian suresh at lama.enet.dec.com
Fri Feb 15 05:54:26 AEST 1991


    The scenario goes like this

      if  (!fork()) {
        fd = socket(.....); /* Unix domain */
        bind and listen for connection
         accept(...)
          close(0) dup2(fd,0);
          close(1); dup2(fd,1);
          close(2); dup2(fd,2);
         execl("tip", "tip", args, (char *)0);   /*  standard unix tip, */
     } else {
         sock = socket(...)       
        connect(...);
        parent process goes on and exits.
    }
(SIGCLD is also installed for notifying child's death)

   The main program is kind of a supervisor. Keeps waiting for user
input and does appropriate
    actions.  The problem I am facing is this:-

   1) When a user wants to login to a another machine he calls the above
mentioned function.
         I go ahead and exec tip and wait for tip to make the connection
and send me a "login:"
      prompt. I get it and all goes well.
   
      But if the number dialled by tip is a lat then  I will not
      get the standard login prompt. But instead I will get the LAT
prompt and tip will be waiting
      for input from the user. Now the supervisor (that's me) should
know that I have to get the
      input from the user and send it to tip.  But  I don't know that
since I did not get the standard
      "login: " prompt but a LAT prompt. I cannot forsee all possible
lat prompts. 

      An elegant solution would be to get signal from tip, when it is
waiting to do IO.  I know there
      is SIGIO to do that. But I have execed tip within a child process.
So the function address that
      I pass to signal system call before execing tip is now meaningless
within the tip program.

       A solution is to modify tip  to send SIGIO. But is there any
other way to get the job done?

Many Thanks for any insight

Suresh
      



More information about the Comp.unix.wizards mailing list