mailing list of musl libc
 help / color / mirror / code / Atom feed
* [PATCH] add support for POSIX_SPAWN_SETSID
@ 2017-03-31  5:02 daurnimator
  2017-03-31 16:01 ` Rich Felker
  0 siblings, 1 reply; 6+ messages in thread
From: daurnimator @ 2017-03-31  5:02 UTC (permalink / raw)
  To: musl; +Cc: daurnimator

This patch adds support for the POSIX_SPAWN_SETSID flag.

It was recently accepted by the Austin Group:
http://austingroupbugs.net/view.php?id=1044

---
 include/spawn.h           | 1 +
 src/process/posix_spawn.c | 4 ++++
 2 files changed, 5 insertions(+)

diff --git a/include/spawn.h b/include/spawn.h
index 29c799ee..7dee7cfa 100644
--- a/include/spawn.h
+++ b/include/spawn.h
@@ -21,6 +21,7 @@ struct sched_param;
 #define POSIX_SPAWN_SETSIGMASK 8
 #define POSIX_SPAWN_SETSCHEDPARAM 16
 #define POSIX_SPAWN_SETSCHEDULER 32
+#define POSIX_SPAWN_SETSID 64
 
 typedef struct {
 	int __flags;
diff --git a/src/process/posix_spawn.c b/src/process/posix_spawn.c
index 0bdf71cd..03392ba8 100644
--- a/src/process/posix_spawn.c
+++ b/src/process/posix_spawn.c
@@ -73,6 +73,10 @@ static int child(void *args_vp)
 		__libc_sigaction(i, &sa, 0);
 	}
 
+	if (attr->__flags & POSIX_SPAWN_SETSID)
+		if ((ret=__syscall(SYS_setsid)))
+			goto fail;
+
 	if (attr->__flags & POSIX_SPAWN_SETPGROUP)
 		if ((ret=__syscall(SYS_setpgid, 0, attr->__pgrp)))
 			goto fail;
-- 
2.12.1



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] add support for POSIX_SPAWN_SETSID
  2017-03-31  5:02 [PATCH] add support for POSIX_SPAWN_SETSID daurnimator
@ 2017-03-31 16:01 ` Rich Felker
  2017-04-22 23:19   ` Rich Felker
  0 siblings, 1 reply; 6+ messages in thread
From: Rich Felker @ 2017-03-31 16:01 UTC (permalink / raw)
  To: musl; +Cc: libc-alpha

On Fri, Mar 31, 2017 at 04:02:43PM +1100, daurnimator wrote:
> This patch adds support for the POSIX_SPAWN_SETSID flag.
> 
> It was recently accepted by the Austin Group:
> http://austingroupbugs.net/view.php?id=1044
> 
> ---
>  include/spawn.h           | 1 +
>  src/process/posix_spawn.c | 4 ++++
>  2 files changed, 5 insertions(+)
> 
> diff --git a/include/spawn.h b/include/spawn.h
> index 29c799ee..7dee7cfa 100644
> --- a/include/spawn.h
> +++ b/include/spawn.h
> @@ -21,6 +21,7 @@ struct sched_param;
>  #define POSIX_SPAWN_SETSIGMASK 8
>  #define POSIX_SPAWN_SETSCHEDPARAM 16
>  #define POSIX_SPAWN_SETSCHEDULER 32
> +#define POSIX_SPAWN_SETSID 64

This overlaps with the glibc value for POSIX_SPAWN_USEVFORK; while we
don't implement it, we also don't want to have mismatched constant
ABI.

I know this is asking a lot, but could you possibly submit a glibc
patch too so the intended value (128 I guess?) is established on their
side too, or (yay if you can!) poke somebody else to do it? In the
past I've tried to just get them to casually agree to assigning values
for things like this before they implement them, but I haven't had
much luck.

Cc'ing libc-alpha too.

Rich


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] add support for POSIX_SPAWN_SETSID
  2017-03-31 16:01 ` Rich Felker
@ 2017-04-22 23:19   ` Rich Felker
  2017-04-22 23:43     ` [musl] " Zack Weinberg
  0 siblings, 1 reply; 6+ messages in thread
From: Rich Felker @ 2017-04-22 23:19 UTC (permalink / raw)
  To: musl, libc-alpha

On Fri, Mar 31, 2017 at 12:01:56PM -0400, Rich Felker wrote:
> On Fri, Mar 31, 2017 at 04:02:43PM +1100, daurnimator wrote:
> > This patch adds support for the POSIX_SPAWN_SETSID flag.
> > 
> > It was recently accepted by the Austin Group:
> > http://austingroupbugs.net/view.php?id=1044
> > 
> > ---
> >  include/spawn.h           | 1 +
> >  src/process/posix_spawn.c | 4 ++++
> >  2 files changed, 5 insertions(+)
> > 
> > diff --git a/include/spawn.h b/include/spawn.h
> > index 29c799ee..7dee7cfa 100644
> > --- a/include/spawn.h
> > +++ b/include/spawn.h
> > @@ -21,6 +21,7 @@ struct sched_param;
> >  #define POSIX_SPAWN_SETSIGMASK 8
> >  #define POSIX_SPAWN_SETSCHEDPARAM 16
> >  #define POSIX_SPAWN_SETSCHEDULER 32
> > +#define POSIX_SPAWN_SETSID 64
> 
> This overlaps with the glibc value for POSIX_SPAWN_USEVFORK; while we
> don't implement it, we also don't want to have mismatched constant
> ABI.
> 
> I know this is asking a lot, but could you possibly submit a glibc
> patch too so the intended value (128 I guess?) is established on their
> side too, or (yay if you can!) poke somebody else to do it? In the
> past I've tried to just get them to casually agree to assigning values
> for things like this before they implement them, but I haven't had
> much luck.
> 
> Cc'ing libc-alpha too.

Thanks for all your work on this! Based on the glibc patch review, I'm
changing the error condition from !=0 to <0, and of course changing
the flag value to 128 to match.

Rich


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [musl] [PATCH] add support for POSIX_SPAWN_SETSID
  2017-04-22 23:19   ` Rich Felker
@ 2017-04-22 23:43     ` Zack Weinberg
  2017-04-22 23:47       ` Rich Felker
  0 siblings, 1 reply; 6+ messages in thread
From: Zack Weinberg @ 2017-04-22 23:43 UTC (permalink / raw)
  To: Rich Felker; +Cc: musl, GNU C Library

On Sat, Apr 22, 2017 at 7:19 PM, Rich Felker <dalias@libc.org> wrote:
>> >  #define POSIX_SPAWN_SETSIGMASK 8
>> >  #define POSIX_SPAWN_SETSCHEDPARAM 16
>> >  #define POSIX_SPAWN_SETSCHEDULER 32
>> > +#define POSIX_SPAWN_SETSID 64
>>
>> This overlaps with the glibc value for POSIX_SPAWN_USEVFORK; while we
>> don't implement it, we also don't want to have mismatched constant
>> ABI.
...
> Thanks for all your work on this! Based on the glibc patch review, I'm
> changing the error condition from !=0 to <0, and of course changing
> the flag value to 128 to match.

May I suggest that musl include a note in its headers, explaining that
bit 64 is reserved to avoid an ABI conflict with glibc?  Then the next
time there's an addition, there will be less confusion.

zw


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] add support for POSIX_SPAWN_SETSID
  2017-04-22 23:43     ` [musl] " Zack Weinberg
@ 2017-04-22 23:47       ` Rich Felker
  2017-04-22 23:49         ` [musl] " Zack Weinberg
  0 siblings, 1 reply; 6+ messages in thread
From: Rich Felker @ 2017-04-22 23:47 UTC (permalink / raw)
  To: musl, GNU C Library

On Sat, Apr 22, 2017 at 07:43:01PM -0400, Zack Weinberg wrote:
> On Sat, Apr 22, 2017 at 7:19 PM, Rich Felker <dalias@libc.org> wrote:
> >> >  #define POSIX_SPAWN_SETSIGMASK 8
> >> >  #define POSIX_SPAWN_SETSCHEDPARAM 16
> >> >  #define POSIX_SPAWN_SETSCHEDULER 32
> >> > +#define POSIX_SPAWN_SETSID 64
> >>
> >> This overlaps with the glibc value for POSIX_SPAWN_USEVFORK; while we
> >> don't implement it, we also don't want to have mismatched constant
> >> ABI.
> ....
> > Thanks for all your work on this! Based on the glibc patch review, I'm
> > changing the error condition from !=0 to <0, and of course changing
> > the flag value to 128 to match.
> 
> May I suggest that musl include a note in its headers, explaining that
> bit 64 is reserved to avoid an ABI conflict with glibc?  Then the next
> time there's an addition, there will be less confusion.

I was actually thinking of just adding POSIX_SPAWN_USEVFORK as a nop.
I think it will eventually be a nop on glibc too; maybe it already is
on Linux targets. Then we can have posix_spawnattr_setflags check
against all valid flags and return EINVAL if an unknown bit is set, so
that applications can runtime-probe for any future functionality
additions.

Rich


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [musl] [PATCH] add support for POSIX_SPAWN_SETSID
  2017-04-22 23:47       ` Rich Felker
@ 2017-04-22 23:49         ` Zack Weinberg
  0 siblings, 0 replies; 6+ messages in thread
From: Zack Weinberg @ 2017-04-22 23:49 UTC (permalink / raw)
  To: Rich Felker; +Cc: musl, GNU C Library

On Sat, Apr 22, 2017 at 7:47 PM, Rich Felker <dalias@libc.org> wrote:
> On Sat, Apr 22, 2017 at 07:43:01PM -0400, Zack Weinberg wrote:
>> On Sat, Apr 22, 2017 at 7:19 PM, Rich Felker <dalias@libc.org> wrote:
>> >> >  #define POSIX_SPAWN_SETSIGMASK 8
>> >> >  #define POSIX_SPAWN_SETSCHEDPARAM 16
>> >> >  #define POSIX_SPAWN_SETSCHEDULER 32
>> >> > +#define POSIX_SPAWN_SETSID 64
>> >>
>> >> This overlaps with the glibc value for POSIX_SPAWN_USEVFORK; while we
>> >> don't implement it, we also don't want to have mismatched constant
>> >> ABI.
>> ....
>> > Thanks for all your work on this! Based on the glibc patch review, I'm
>> > changing the error condition from !=0 to <0, and of course changing
>> > the flag value to 128 to match.
>>
>> May I suggest that musl include a note in its headers, explaining that
>> bit 64 is reserved to avoid an ABI conflict with glibc?  Then the next
>> time there's an addition, there will be less confusion.
>
> I was actually thinking of just adding POSIX_SPAWN_USEVFORK as a nop.
> I think it will eventually be a nop on glibc too; maybe it already is
> on Linux targets. Then we can have posix_spawnattr_setflags check
> against all valid flags and return EINVAL if an unknown bit is set, so
> that applications can runtime-probe for any future functionality
> additions.

Makes sense.

zw


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-04-22 23:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-31  5:02 [PATCH] add support for POSIX_SPAWN_SETSID daurnimator
2017-03-31 16:01 ` Rich Felker
2017-04-22 23:19   ` Rich Felker
2017-04-22 23:43     ` [musl] " Zack Weinberg
2017-04-22 23:47       ` Rich Felker
2017-04-22 23:49         ` [musl] " Zack Weinberg

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).