Clément Lassieur <[email protected]> writes: > Ludovic Courtès <[email protected]> writes: > >> Clément Lassieur <[email protected]> skribis: >> >>> Fixes <https://bugs.gnu.org/29992>. >>> >>> * gnu/services/databases.scm (postgresql-shepherd-service): Replace >>> make-forkexec-constructor and make-kill-destructor with pg_ctl. >> >> [...] >> >>> + (let* ((pg_ctl-wrapper >>> + ;; Wrapper script that switches to the 'postgres' user before >>> + ;; launching daemon. >>> + (program-file >>> + "pg_ctl-wrapper" >>> + #~(begin >>> + (use-modules (ice-9 match) >>> + (ice-9 format)) >>> + (match (command-line) >>> + ((_ mode) >>> + (let ((user (getpwnam "postgres")) >>> + (pg_ctl #$(file-append postgresql >>> "/bin/pg_ctl"))) >>> + (setgid (passwd:gid user)) >>> + (setuid (passwd:uid user)) >>> + (system >>> + (format #f "~a -D ~a -o '--config-file=~a -p ~d' >>> ~a" >>> + pg_ctl #$data-directory #$config-file >>> #$port >>> + mode)))))))) >> >> I think we should use ‘execl’ here instead of ‘system’ so that (1) the >> exit code is correct, and (2) we don’t go through /bin/sh. > > Hi Ludovic, thank you for the review. > > How do you pass single quotes as an ‘execl’ argument? > > https://www.postgresql.org/docs/9.3/static/app-pg-ctl.html says: > --8<---------------cut here---------------start------------->8--- > -o options > Specifies options to be passed directly to the postgres command. > The options should usually be surrounded by single or double quotes > to ensure that they are passed through as a group. > --8<---------------cut here---------------end--------------->8---
Oh I understood this. I'll do a new patch. > Also, I don't understand how the exit code matters since Guile scripts > seem to always return 0, no matter if the last return value is true or > false. > > Clément
