OS X patch for run_erl.c

ernie.makris <>
Tue Dec 7 18:57:24 CET 2004


Hello Jouni,

I have one addition to the patch:

{
>     static char ttyname[] = "                                   ";
> 
>     if (0 == openpty(&mfd, &sfd, ttyname, NULL, NULL)) {
>       close(sfd);    /* ADDED THIS */
>       *ptyslave = ttyname;
>       return mfd;
>     }
>   }

If the slave fd is not closed, the parent never gets the close indication and run_erl runs forever after the erl process has ended.

Thanks
Ernie


> Here's my diff (from some version .. of run_erl.c)
> 
> 47a48,49
> > #include <pty.h>
> > #include <utmp.h>
> 153c155
> < 	      program_name, (int)(Need), FILENAME_BUFSIZ));		   \
> ---
> > 	      program_name, (Need), FILENAME_BUFSIZ));			   \
> 608c610
> < static int find_next_log_num(void) {
> ---
> > static int find_next_log_num() {
> 753a756
> >   int sfd;
> 820a824,831
> >   {
> >     static char ttyname[] = "                                   ";
> > 
> >     if (0 == openpty(&mfd, &sfd, ttyname, NULL, NULL)) {
> >       *ptyslave = ttyname;
> >       return mfd;
> >     }
> >   }
> 
> On Tue, 2004-12-07 at 08:46 -0500, Ernie Makris wrote:
> > Hi Jouni,
> > 
> > Can you send me the full patch for run_erl.c. I too am trying to execute
> > run_erl under
> > Fedora Core 3 and having problems.
> > 
> > Thanks
> > Ernie
> > ----- Original Message ----- 
> > From: "Jouni Rynö" <>
> > To: "Bjorn Gustavsson" <>
> > Cc: <>
> > Sent: Tuesday, December 07, 2004 5:43 AM
> > Subject: Re: OS X patch for run_erl.c
> > 
> > 
> > > I still have the problem with Linux 2.6 kernel and udev etc,
> > > run_erl [19205] Tue Dec  7 12:40:01 2004
> > > Could not open pty master
> > >
> > > Fixed it with my own version of it, with a call to
> > >
> > >  #include <pty.h>
> > >  #include <utmp.h>
> > >
> > >  {
> > >      static char ttyname[] = "                                   ";
> > >
> > >      if (0 == openpty(&mfd, &sfd, ttyname, NULL, NULL)) {
> > >        *ptyslave = ttyname;
> > >        return mfd;
> > >      }
> > >    }
> > >
> > >
> > > On Mon, 2004-12-06 at 14:14 +0100, Bjorn Gustavsson wrote:
> > > > Thanks!
> > > >
> > > > We have look at this issue. I can't promise we'll be able to do that
> > > > for R10B-2.
> > > >
> > > > /Bjorn
> > > >
> > > > "Peter L" <> writes:
> > > >
> > > > > This Sunday I discovered that my FreeBSD 4.3 had exactly the same
> > > > > problem as Sean had in his OS X, with mknod/mkfifo in the run_erl.c
> > > > > file. When I applied the same patch as Sean did I was able to start
> > > > > erlang as a daemon, which I had not been able to do before on FreeBSD.
> > > > >
> > > > > Looking at this file run_erl.c in the latest R10B-1a version of
> > > > > OTP/Erlang, I was still unable to see any fix for this problem,
> > > > > despite it being well over a year since Sean reported the problem
> > > > > the first time.
> > > > >
> > > > > Is it in Erlang or in FreeBSD / OS X, where the problem needs to be
> > > > > fixed? Because I guess that Erlang is supposed to support also OS X
> > > > > and FreeBSD...
> > > > >
> > > > > A maybe related problem I had, was that I was not able to attach
> > > > > properly to the erlang daemon with the supplied bin/to_erl. Is there
> > > > > perhaps another fix that has to be applied for this to work under
> > > > > FreeBSD or OS X? Sean, any idea?
> > > > >
> > > > > /Peter
> > > > >
> > > > > %% ============ From the erlang list archive ===============
> > > > >
> > > > >     * To: Bengt Kleberg
> > > > >     * Subject: Re: OS X patch for run_erl.c
> > > > >     * From: Sean Hinde
> > > > >     * Date: Fri, 19 Sep 2003 23:46:54 +0100
> > > > >     * Cc: Erlang Questions
> > > > >
> > > > > On Monday, September 15, 2003, at 09:07  am, Bengt Kleberg wrote:
> > > > >
> > > > > > Sean Hinde wrote:
> > > > > >> Hi,
> > > > > >> The following patch to run_erl.c is required for Erlang to run in
> > > > > >> embedded mode under OS X. Without this patch run_erl fails to
> > create
> > > > > >> the
> > > > > >
> > > > > > ...deleted
> > > > > >> +#ifdef HAVE_MACH_O_DYLD_H
> > > > > >> +  if ((mkfifo(name, perm) < 0) && (errno != EEXIST))
> > > > > >> +#else
> > > > > >> +    if ((mknod(name, S_IFIFO | perm, 0) < 0) && (errno != EEXIST))
> > > > > >> +#endif
> > > > > >
> > > > > > perhaps mkfifo() is deprecated (or something even worse :-), but
> > would
> > > > > > it not have been better to test like this:
> > > > > >
> > > > > > #ifdef HAVE_MKFIFO
> > > > > > if ((mkfifo(name, perm) < 0) && (errno != EEXIST))
> > > > > > #else
> > > > > > if ((mknod(name, S_IFIFO | perm, 0) < 0) && (errno != EEXIST))
> > > > > > #endif
> > > > > >
> > > > >
> > > > > No doubt. I leave it to the real maintainers of Erlang to take care of
> > > > > elegance in the build process. All this difficult cross platform C
> > > > > stuff is light years from anything I claim competence in, beyond the
> > > > > annoying necessity to occasionally waste many hours making Erlang work
> > > > > on my favourite laptop :)
> > > > >
> > > > > Sean
> > > > >
> > > > >
> > > > > -- 
> > > > > Peter Lund
> > > > > Web: http://lundata.se
> > > > > Tel: +46 70 543 9416
> > > > >
> > > >
> > > -- 
> > >
> > >   Jouni Rynö                            mailto://Jouni.Ryno@fmi.fi/
> > >                                         http://www.geo.fmi.fi/~ryno/
> > >   Finnish Meteorological Institute      http://www.fmi.fi/
> > >   Space Research                        http://www.geo.fmi.fi/
> > >   P.O.BOX 503                           Tel      (+358)-9-19294656
> > >   FIN-00101 Helsinki                    FAX      (+358)-9-19294603
> > >   Finland                               priv-GSM (+358)-50-5302903
> > >
> > >   "It's just zeros and ones, it cannot be hard"
> > >
> > >
> > 
> -- 
> 
>   Jouni Rynö                            mailto://Jouni.Ryno@fmi.fi/
>                                         http://www.geo.fmi.fi/~ryno/
>   Finnish Meteorological Institute      http://www.fmi.fi/
>   Space Research                        http://www.geo.fmi.fi/
>   P.O.BOX 503                           Tel      (+358)-9-19294656
>   FIN-00101 Helsinki                    FAX      (+358)-9-19294603
>   Finland                               priv-GSM (+358)-50-5302903
>   
>   "It's just zeros and ones, it cannot be hard"
> 
> 



More information about the erlang-questions mailing list