Re: [HACKERS] New pg_ctl has retrogressed in error messages

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: [HACKERS] New pg_ctl has retrogressed in error messages
Date: 2004-06-01 01:27:43
Message-ID: 200406010127.i511Rhh14888@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox
Thread:
Lists: pgsql-hackers pgsql-patches

Andrew Dunstan wrote:
>
> >this code will fail rather horribly if sizeof(pid_t) != sizeof(int).
> >Even more to the point, I believe a standalone backend will put
> >the negative of its PID into the file, and the revised code will fail
> >to parse that at all.
> >
> >I think the safest code would be like
> >
> > long tmp;
> >
> > fscanf(pidf, "%ld", &tmp);
> > if (tmp < 0)
> > {
> > tmp = -tmp;
> > // do anything else needed for backend case
> > }
> > pid = (pid_t) tmp;
> >
> >
> >
> >
>
> I deliberately used a signed long for these reasons in the first place.
>
> The number of places we actually need to use this value as a pid is
> small (3 by my count - in calls to kill() ), and it was cast there to
> pid_t, I think. I still don't see what's wrong with that.

OK, I created a typedef pgpid_t equal to long and used that in the code,
change format to %ld, and documented why negative values are an issue.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Oliver Jowett 2004-06-01 01:32:32 Re: Official Freeze Date for 7.5: July 1st, 2004
Previous Message Andrew Dunstan 2004-06-01 01:07:07 Re: [HACKERS] New pg_ctl has retrogressed in error messages

Browse pgsql-patches by date

  From Date Subject
Next Message Bruce Momjian 2004-06-01 02:01:34 Re: CVS tip problems
Previous Message Andrew Dunstan 2004-06-01 01:07:07 Re: [HACKERS] New pg_ctl has retrogressed in error messages