* [bug#49839] [PATCH] shepherd: add keep-tty flag to skip setsid
@ 2021-08-03 1:07 muradm
2021-08-10 12:51 ` bug#49839: " Ludovic Courtès
0 siblings, 1 reply; 4+ messages in thread
From: muradm @ 2021-08-03 1:07 UTC (permalink / raw)
To: 49839
[-- Attachment #1: Type: text/plain, Size: 448 bytes --]
* modules/shepherd/service.scm: add keep-tty flag to skip setsid
when using shepherd as user, programs like xorg server,
potentially any
program which ends up interacting with user, require terminal to
remain.
currently, setsid is called unconditionally from exec-command
function,
making it impossible to have such process.
this adds keep-tty flag to make-forkexec-constructor up to
exec-command
function where setsid is actually called.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: shepherd-keep-tty.patch --]
[-- Type: text/x-patch, Size: 3072 bytes --]
diff --git a/modules/shepherd/service.scm b/modules/shepherd/service.scm
index 587ff68..1ae9544 100644
--- a/modules/shepherd/service.scm
+++ b/modules/shepherd/service.scm
@@ -786,6 +786,7 @@ daemon writing FILE is running in a separate PID namespace."
(log-file #f)
(directory (default-service-directory))
(file-creation-mask #f)
+ (keep-tty #f)
(environment-variables (default-environment-variables)))
"Run COMMAND as the current process from DIRECTORY, with FILE-CREATION-MASK
if it's true, and with ENVIRONMENT-VARIABLES (a list of strings like
@@ -804,7 +805,7 @@ false."
((program args ...)
;; Become the leader of a new session and session group.
;; Programs such as 'mingetty' expect this.
- (setsid)
+ (unless keep-tty (setsid))
(chdir directory)
(environ environment-variables)
@@ -889,6 +890,7 @@ false."
(log-file #f)
(directory (default-service-directory))
(file-creation-mask #f)
+ (keep-tty #f)
(environment-variables
(default-environment-variables)))
"Spawn a process that executed COMMAND as per 'exec-command', and return
@@ -920,6 +922,7 @@ its PID."
#:log-file log-file
#:directory directory
#:file-creation-mask file-creation-mask
+ #:keep-tty keep-tty
#:environment-variables environment-variables))
pid))))
@@ -929,6 +932,7 @@ its PID."
(group #f)
(supplementary-groups '())
(directory (default-service-directory))
+ (keep-tty #f)
(environment-variables
(default-environment-variables))
(file-creation-mask #f)
@@ -949,7 +953,9 @@ When @var{pid-file} is true, it must be the name of a PID file associated with
the process being launched; the return value is the PID read from that file,
once that file has been created. If @var{pid-file} does not show up in less
than @var{pid-file-timeout} seconds, the service is considered as failing to
-start."
+start.
+
+When @var{keep-tty} is true, will not call @code{setsid} for process."
(lambda args
(define (clean-up file)
(when file
@@ -969,6 +975,7 @@ start."
#:log-file log-file
#:directory directory
#:file-creation-mask file-creation-mask
+ #:keep-tty keep-tty
#:environment-variables
environment-variables)))
(if pid-file
^ permalink raw reply related [flat|nested] 4+ messages in thread
* bug#49839: [PATCH] shepherd: add keep-tty flag to skip setsid
2021-08-03 1:07 [bug#49839] [PATCH] shepherd: add keep-tty flag to skip setsid muradm
@ 2021-08-10 12:51 ` Ludovic Courtès
2021-08-10 21:08 ` [bug#49839] " muradm
0 siblings, 1 reply; 4+ messages in thread
From: Ludovic Courtès @ 2021-08-10 12:51 UTC (permalink / raw)
To: muradm; +Cc: 49839-done
Hi,
muradm <mail@muradm.net> skribis:
> * modules/shepherd/service.scm: add keep-tty flag to skip setsid
>
> when using shepherd as user, programs like xorg server, potentially
> any
> program which ends up interacting with user, require terminal to
> remain.
>
> currently, setsid is called unconditionally from exec-command
> function,
> making it impossible to have such process.
>
> this adds keep-tty flag to make-forkexec-constructor up to
> exec-command
> function where setsid is actually called.
>
> diff --git a/modules/shepherd/service.scm b/modules/shepherd/service.scm
> index 587ff68..1ae9544 100644
> --- a/modules/shepherd/service.scm
> +++ b/modules/shepherd/service.scm
> @@ -786,6 +786,7 @@ daemon writing FILE is running in a separate PID namespace."
> (log-file #f)
> (directory (default-service-directory))
> (file-creation-mask #f)
> + (keep-tty #f)
> (environment-variables (default-environment-variables)))
> "Run COMMAND as the current process from DIRECTORY, with FILE-CREATION-MASK
> if it's true, and with ENVIRONMENT-VARIABLES (a list of strings like
> @@ -804,7 +805,7 @@ false."
> ((program args ...)
> ;; Become the leader of a new session and session group.
> ;; Programs such as 'mingetty' expect this.
> - (setsid)
> + (unless keep-tty (setsid))
I did that slightly differently:
https://git.savannah.gnu.org/cgit/shepherd.git/commit/?id=c43f81794344dbac31bcb8b8f1c0d266f47f14fa
Let me know if it works for you.
Thanks,
Ludo’.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [bug#49839] [PATCH] shepherd: add keep-tty flag to skip setsid
2021-08-10 12:51 ` bug#49839: " Ludovic Courtès
@ 2021-08-10 21:08 ` muradm
2021-08-11 9:57 ` Ludovic Courtès
0 siblings, 1 reply; 4+ messages in thread
From: muradm @ 2021-08-10 21:08 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: 49839-done
Hi,
Basically it is samething, should work.
Any idea when to expect it in public?
Thanks in advance,
muradm
Ludovic Courtès <ludo@gnu.org> writes:
> Hi,
>
> muradm <mail@muradm.net> skribis:
>
>> * modules/shepherd/service.scm: add keep-tty flag to skip
>> setsid
>>
>> when using shepherd as user, programs like xorg server,
>> potentially
>> any
>> program which ends up interacting with user, require terminal
>> to
>> remain.
>>
>> currently, setsid is called unconditionally from exec-command
>> function,
>> making it impossible to have such process.
>>
>> this adds keep-tty flag to make-forkexec-constructor up to
>> exec-command
>> function where setsid is actually called.
>>
>> diff --git a/modules/shepherd/service.scm
>> b/modules/shepherd/service.scm
>> index 587ff68..1ae9544 100644
>> --- a/modules/shepherd/service.scm
>> +++ b/modules/shepherd/service.scm
>> @@ -786,6 +786,7 @@ daemon writing FILE is running in a
>> separate PID namespace."
>> (log-file #f)
>> (directory (default-service-directory))
>> (file-creation-mask #f)
>> + (keep-tty #f)
>> (environment-variables (default-environment-variables)))
>> "Run COMMAND as the current process from DIRECTORY, with
>> FILE-CREATION-MASK
>> if it's true, and with ENVIRONMENT-VARIABLES (a list of
>> strings like
>> @@ -804,7 +805,7 @@ false."
>> ((program args ...)
>> ;; Become the leader of a new session and session group.
>> ;; Programs such as 'mingetty' expect this.
>> - (setsid)
>> + (unless keep-tty (setsid))
>
> I did that slightly differently:
>
> https://git.savannah.gnu.org/cgit/shepherd.git/commit/?id=c43f81794344dbac31bcb8b8f1c0d266f47f14fa
>
> Let me know if it works for you.
>
> Thanks,
> Ludo’.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [bug#49839] [PATCH] shepherd: add keep-tty flag to skip setsid
2021-08-10 21:08 ` [bug#49839] " muradm
@ 2021-08-11 9:57 ` Ludovic Courtès
0 siblings, 0 replies; 4+ messages in thread
From: Ludovic Courtès @ 2021-08-11 9:57 UTC (permalink / raw)
To: muradm; +Cc: 49839-done
Hi,
muradm <mail@muradm.net> skribis:
> Basically it is samething, should work.
> Any idea when to expect it in public?
There are no planned Shepherd releases currently, we’ll see…
Thanks,
Ludo’.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-08-11 9:58 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-03 1:07 [bug#49839] [PATCH] shepherd: add keep-tty flag to skip setsid muradm
2021-08-10 12:51 ` bug#49839: " Ludovic Courtès
2021-08-10 21:08 ` [bug#49839] " muradm
2021-08-11 9:57 ` Ludovic Courtès
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).