From 3d7b8105e1385c835cf0660797fe70198097e73d Mon Sep 17 00:00:00 2001 From: Tiago Cunha Date: Tue, 15 Feb 2011 15:20:03 +0000 Subject: Sync OpenBSD patchset 855: Simplify the way jobs work and drop the persist type, so all jobs are fire-and-forget. Status jobs now managed with two trees of output (new and old), rather than storing the output in the jobs themselves. When the status line is processed any jobs which don't appear in the new tree are started and the output from the old tree displayed. When a job finishes it updates the new tree with its output and that is used for any subsequent redraws. When the status interval expires, the new tree is moved to the old so that all jobs are run again. This fixes the "#(echo %H:%M:%S)" problem which would lead to thousands of identical persistent jobs and high memory use (this can still be achieved by adding "sleep 30" but that is much less likely to happen by accident). --- cmd-if-shell.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'cmd-if-shell.c') diff --git a/cmd-if-shell.c b/cmd-if-shell.c index 829102d9..d9dc3877 100644 --- a/cmd-if-shell.c +++ b/cmd-if-shell.c @@ -1,4 +1,4 @@ -/* $Id: cmd-if-shell.c,v 1.11 2011-01-07 14:45:34 tcunha Exp $ */ +/* $Id: cmd-if-shell.c,v 1.12 2011-02-15 15:20:03 tcunha Exp $ */ /* * Copyright (c) 2009 Tiago Cunha @@ -53,7 +53,7 @@ cmd_if_shell_exec(struct cmd *self, struct cmd_ctx *ctx) { struct args *args = self->args; struct cmd_if_shell_data *cdata; - struct job *job; + const char *shellcmd = args->argv[0]; cdata = xmalloc(sizeof *cdata); cdata->cmd = xstrdup(args->argv[1]); @@ -64,9 +64,7 @@ cmd_if_shell_exec(struct cmd *self, struct cmd_ctx *ctx) if (ctx->curclient != NULL) ctx->curclient->references++; - job = job_add(NULL, 0, NULL, - args->argv[0], cmd_if_shell_callback, cmd_if_shell_free, cdata); - job_run(job); + job_run(shellcmd, cmd_if_shell_callback, cmd_if_shell_free, cdata); return (1); /* don't let client exit */ } -- cgit