* Re: branch master updated: doc: Recommend avoiding execl, execle or execlp in mcron job specifications.
2022-12-02 9:32 ` branch master updated: doc: Recommend avoiding execl, execle or execlp in mcron job specifications Ludovic Courtès
@ 2022-12-04 5:10 ` Maxim Cournoyer
0 siblings, 0 replies; 2+ messages in thread
From: Maxim Cournoyer @ 2022-12-04 5:10 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: guix-devel
Hi Ludovic,
Ludovic Courtès <ludo@gnu.org> writes:
> Hello,
>
> guix-commits@gnu.org skribis:
>
>> diff --git a/doc/guix.texi b/doc/guix.texi
>> index e547d469f4..caa6976a82 100644
>> --- a/doc/guix.texi
>> +++ b/doc/guix.texi
>> @@ -18940,9 +18940,8 @@ gexps to introduce job definitions that are passed to mcron
>> ;; job's action as a Scheme procedure.
>> #~(job '(next-hour '(3))
>> (lambda ()
>> - (execl (string-append #$findutils "/bin/updatedb")
>> - "updatedb"
>> - "--prunepaths=/tmp /var/tmp /gnu/store"))
>> + (system* (string-append #$findutils "/bin/updatedb")
>> + "--prunepaths=/tmp /var/tmp /gnu/store"))
>> "updatedb"))
>>
>> (define garbage-collector-job
>> @@ -18980,6 +18979,12 @@ the job would appear as ``Lambda function'' in the output of
>> @command{herd schedule mcron}, which is not nearly descriptive enough!
>> @end quotation
>>
>> +@quotation Tip
>> +Avoid calling the Guile procedures @code{execl}, @code{execle} or
>> +@code{execlp} inside a job specification, else mcron won't be able to
>> +output the completion status of the job.
>> +@end quotation
>
> The problem is that this creates an additional process and the first one
> now just sits there in ‘waitpid’.
>
> Could mcron return the completion status of the process that calls the
> thunk? It suppose it’s already monitoring it (via SIGCHLD or a direct
> ‘waitpid’ call) so it should have that info available, no?
Yes, that should be possible, and I agree that's desirable. We'd have
to move the finalization logging from 'run-job' to 'child-cleanup', both
defined in (mcron base), moving or factoring out 'seconds-since' and
also recording the start date of the job in the <job-data> record
returned by 'run-job'.
My personal mcron TODO now reads:
--8<---------------cut here---------------start------------->8---
* mcron
** TODO Add a 'test' command to run scheduled action *now*
** TODO Log job completion status upon SIGCHLD
--8<---------------cut here---------------end--------------->8---
But feel free to beat me to it!
--
Thanks,
Maxim
^ permalink raw reply [flat|nested] 2+ messages in thread