This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH v3][BZ 21340] add support for POSIX_SPAWN_SETSID
On 21/04/2017 17:04, Florian Weimer wrote:
> * Adhemerval Zanella:
>
>> +static int
>> +do_test_setsid (bool test_setsid)
>
> This should return void.
Ack.
>
>> + if (test_setsid)
>> + {
>> + if (posix_spawnattr_setflags (&attrp, POSIX_SPAWN_SETSID))
>> + FAIL_EXIT1 ("posix_spawnattr_setflags: %m");
>> + }
>
> You need to set errno before you can use %m.
Ack.
>
>> + res = posix_spawnp (&child, "true", NULL, &attrp, args, environ);
>> + /* posix_spawnattr_destroy is noop. */
>> + posix_spawnattr_destroy (&attrp);
>> +
>> + if (res != 0)
>> + FAIL_EXIT1 ("posix_spawnp: %m");
>
> Likewise.
Ack.
>
>> +static int
>> +do_test (void)
>> +{
>> + int ret = 0;
>> +
>> + ret += do_test_setsid (false);
>> + ret += do_test_setsid (true);
>> +
>> + return 0;
>> +}
>
> ret is effectively unused.
Yeah, I though about doing that since we bail out with an exit for
failure. I will change it.
>
>> diff --git a/sysdeps/unix/sysv/linux/spawni.c b/sysdeps/unix/sysv/linux/spawni.c
>> index d7f9e83..3cf77d5 100644
>> --- a/sysdeps/unix/sysv/linux/spawni.c
>> +++ b/sysdeps/unix/sysv/linux/spawni.c
>
>> + if ((attr->__flags & POSIX_SPAWN_SETSID) != 0
>> + && (ret = __setsid ()) < 0)
>> + goto fail;
>
> I believe the assignment to ret is dead.
>
>> +
>> /* Set the process group ID. */
>> if ((attr->__flags & POSIX_SPAWN_SETPGROUP) != 0
>> && (ret = __setpgid (0, attr->__pgrp)) != 0)
>
> Apparently, this is an existing problem with the code ...
>
If I recall correctly, on initial iterations for posix_spawn rewrite I used the ret
return to signal the error, but it seems later I generalize to use errno instead.
I will fix this usage, but I think extra fixes should go to on a different patch.