For the TimedMediaHandler I was adding more fine grain control over
background processes [1] and ran into a unix issue around getting both a
pid and exit status for a given background shell command.

Essentially with a background task I can get the pid or the exit status
but can't seem to get both:

to get the pid:
$pid = wfShellExec("nohup nice -n 19 $cmd > /tmp/stdout.log & echo $!";

put the exit status into a file:
$pid = wfShellExec("nohup nice -n 19 $cmd > /tmp/stdout.log && echo $? >
/tmp/exit.status";

But if I try to get both either my exit status is for the "echo pid"
command or my pid is for the "echo exit status" command. It seems like
there should be some shell trick back-reference background tasks or
something

If nothing else I think this could be done with a shell script and pass
in a lot of path targets and use the "wait $pid" command at the end to
grab the exit code of the background process. Did a quick guess at what
this would look like in that same commit[1], but would rather just do
some command line magic instead of putting a .sh script in the extension.

[1] http://www.mediawiki.org/wiki/Special:Code/MediaWiki/90068

peace,
--michael


_______________________________________________
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l

Reply via email to