From: | Andrew Dunstan <andrew(at)dunslane(dot)net> |
---|---|
To: | PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org> |
Subject: | Re: [HACKERS] New pg_ctl has retrogressed in error messages |
Date: | 2004-06-01 01:07:07 |
Message-ID: | 40BBD6BB.2060306@dunslane.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers pgsql-patches |
Tom Lane wrote:
>Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
>
>
>>I also changed all the pid variables to use pid_t.
>>
>>
>
>Good, but ...
>
>
>
>>! fscanf(pidf, "%u", &pid);
>>
>>
>
>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.
cheers
andrew
From | Date | Subject | |
---|---|---|---|
Next Message | Bruce Momjian | 2004-06-01 01:27:43 | Re: [HACKERS] New pg_ctl has retrogressed in error messages |
Previous Message | Claudio Natoli | 2004-06-01 00:55:19 | Re: Can't detect time zone |
From | Date | Subject | |
---|---|---|---|
Next Message | Bruce Momjian | 2004-06-01 01:27:43 | Re: [HACKERS] New pg_ctl has retrogressed in error messages |
Previous Message | Tom Lane | 2004-06-01 00:46:17 | Re: [HACKERS] New pg_ctl has retrogressed in error messages |