Re: getprogname() for IBM z/OS

2016-10-14 Thread Jim Meyering
On Thu, Oct 13, 2016 at 1:10 PM, Jim Meyering wrote: > On Thu, Oct 13, 2016 at 1:50 AM, Pádraig Brady wrote: >> On 13/10/16 02:43, Daniel Richard G. wrote: >>> On Wed, 2016 Oct 12 11:04+0100, Pádraig Brady wrote: You only want to strdup once. So you could use a static to track that

Re: getprogname() for IBM z/OS

2016-10-13 Thread Jim Meyering
On Thu, Oct 13, 2016 at 1:50 AM, Pádraig Brady wrote: > On 13/10/16 02:43, Daniel Richard G. wrote: >> On Wed, 2016 Oct 12 11:04+0100, Pádraig Brady wrote: >>> >>> You only want to strdup once. >>> So you could use a static to track that as is done in the AIX case. >> >> Ah, I see, the program nam

Re: getprogname() for IBM z/OS

2016-10-13 Thread Pádraig Brady
On 13/10/16 02:43, Daniel Richard G. wrote: > On Wed, 2016 Oct 12 11:04+0100, Pádraig Brady wrote: >> >> You only want to strdup once. >> So you could use a static to track that as is done in the AIX case. > > Ah, I see, the program name never changes. > >> You can call free(NULL), so the last 3

Re: getprogname() for IBM z/OS

2016-10-12 Thread Daniel Richard G.
On Wed, 2016 Oct 12 11:04+0100, Pádraig Brady wrote: > > You only want to strdup once. > So you could use a static to track that as is done in the AIX case. Ah, I see, the program name never changes. > You can call free(NULL), so the last 3 ifs are redundant. Revised patch is tested and attache

Re: getprogname() for IBM z/OS

2016-10-12 Thread Pádraig Brady
On 12/10/16 09:51, Daniel Richard G. wrote: > +#elif __MVS__ > + /* > https://www.ibm.com/support/knowledgecenter/SSLTBW_2.1.0/com.ibm.zos.v2r1.bpxbd00/rtwgetp.htm > */ > + char *p = "?"; > + pid_t pid = getpid (); > + int token; > + W_PSPROC buf; > + memset (&buf, 0, sizeof(buf)); > + buf

getprogname() for IBM z/OS

2016-10-12 Thread Daniel Richard G.
Please double-check the use of strdup(), to avoid memory leakage. 2016-10-12 Daniel Richard G. getprogname: port to IBM z/OS * lib/getprogname.c (getprogname) [__MVS__]: Use getpid, w_getpsent and strdup to obtain the program name string. --Daniel -- Daniel Richard