[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug#53063] [PATCH wip-harden-installer 00/14] General improvements to t
From: |
Ludovic Courtès |
Subject: |
[bug#53063] [PATCH wip-harden-installer 00/14] General improvements to the installer |
Date: |
Fri, 07 Jan 2022 14:47:28 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) |
Hello Josselin,
Josselin Poiret <dev@jpoiret.xyz> skribis:
> +(define* (run-external-command-with-handler handler command)
> + "Run command specified by the list COMMAND in a child with output handler
> +HANDLER. HANDLER is a procedure taking an input port, to which the command
> +will write its standard output and error. Returns the integer status value
> of
> +the child process as returned by waitpid."
> + (match-let (((input . output) (pipe)))
> + (match (primitive-fork)
> + (0 ;; We're in the child
> + (close-port input)
> + (reset-fds
> + (open-fdes "/dev/null" O_WRONLY)
> + ;; Avoid port GC'ing closing the fd by increasing its revealed count.
> + (port->fdes output)
> + (fileno output))
> + (with-exception-handler
> + (lambda (exn)
> + ((@@ (ice-9 exceptions) format-exception) (current-error-port)
> + exn)
> + (primitive-_exit 1))
> + (lambda ()
> + (apply execlp (car command) command)
> + (primitive-_exit 1))))
> + (pid
> + (close-port output)
> + (handler input)
> + (close-port input)
> + (cdr (waitpid pid))))))
In general, I recommend using (ice-9 popen) instead of raw
‘primitive-fork’. It provides primitives that do fork+exec at once,
which avoids shenanigans with the finalization threads such as what you
work around in patch #6.
I haven’t looked in detail, but could the ‘pipeline’ procedure from
(ice-9 popen) be of any help?
If you really really do need to fiddle with finalization, I’d recommend
exporting ‘without-automatic-finalization’ from (guix build syscalls)
and using it, so that the hack is factorized.
HTH,
Ludo’.
- [bug#53063] [PATCH wip-harden-installer 00/14] General improvements to the installer, Josselin Poiret, 2022/01/06
- [bug#53063] [PATCH wip-harden-installer 01/14] installer: Use define instead of let at top-level., Josselin Poiret, 2022/01/06
- [bug#53063] [PATCH wip-harden-installer 04/14] installer: Un-export syslog syntax., Josselin Poiret, 2022/01/06
- [bug#53063] [PATCH wip-harden-installer 02/14] installer: Generalize logging facility., Josselin Poiret, 2022/01/06
- [bug#53063] [PATCH wip-harden-installer 03/14] installer: Use new installer-log-line everywhere., Josselin Poiret, 2022/01/06
- [bug#53063] [PATCH wip-harden-installer 05/14] installer: Capture external commands output., Josselin Poiret, 2022/01/06
- [bug#53063] [PATCH wip-harden-installer 00/14] General improvements to the installer,
Ludovic Courtès <=
- [bug#53063] [PATCH wip-harden-installer 06/14] installer: Disable automatic finalization for child thread., Josselin Poiret, 2022/01/06
- [bug#53063] [PATCH wip-harden-installer 07/14] installer: Add installer-specific run command process., Josselin Poiret, 2022/01/06
- [bug#53063] [PATCH wip-harden-installer 08/14] installer: Use run-command-in-installer in (gnu installer parted)., Josselin Poiret, 2022/01/06
- [bug#53063] [PATCH wip-harden-installer 08/14] installer: Use run-command-in-installer in (gnu installer parted)., Mathieu Othacehe, 2022/01/07
- [bug#53063] [PATCH wip-harden-installer 08/14] installer: Use run-command-in-installer in (gnu installer parted)., Josselin Poiret, 2022/01/07
- [bug#53063] [PATCH v2 wip-harden-installer 00/18] General improvements to the installer, Josselin Poiret, 2022/01/15
- [bug#53063] [PATCH v2 wip-harden-installer 04/18] installer: Un-export syslog syntax., Josselin Poiret, 2022/01/15
- [bug#53063] [PATCH v2 wip-harden-installer 03/18] installer: Use new installer-log-line everywhere., Josselin Poiret, 2022/01/15
- [bug#53063] [PATCH v2 wip-harden-installer 08/18] installer: Add installer-specific run command process., Josselin Poiret, 2022/01/15
- [bug#53063] [PATCH v2 wip-harden-installer 06/18] installer: Remove specific logging code., Josselin Poiret, 2022/01/15