[PATCH weston v4] xwm: tell the shell the pid of the X clients

Daniel Stone daniel at fooishbar.org
Tue Jan 27 12:00:08 PST 2015


Hi,

On 27 January 2015 at 19:56, Bill Spitzak <spitzak at gmail.com> wrote:
> On 01/27/2015 06:52 AM, Daniel Stone wrote:
>> POSIX.1-2001 says that if such
>>         truncation occurs, then it is unspecified whether the returned
>> buffer includes a terminating
>>         null byte.
>>
>> I think the best thing to do here would be:
>>    for (i = 0; i < sizeof(name); i++) {
>>        if (name[i] == '\0')
>>            break;
>>    }
>>    if (i == sizeof(name))
>>        name[0] = '\0'; /* ignore stupid hostnames */
>
>
> Or make the buffer 1 larger than you tell the function, and put a zero at
> the end:
>
>    gethostname(buffer, sizeof(buffer)-1);
>    buffer[sizeof(buffer)-1] = '\0';

If the hostname's been truncated, then it's not useful for our purposes.

Cheers,
Daniel


More information about the wayland-devel mailing list