3 * @file src/Model/Process.php
5 namespace Friendica\Model;
7 use Friendica\Database\DBA;
8 use Friendica\Util\DateTimeFormat;
11 * functions for interacting with a process
16 * Insert a new process row. If the pid parameter is omitted, we use the current pid
18 * @param string $command
23 public static function insert($command, $pid = null)
33 if (!DBA::exists('process', ['pid' => $pid])) {
34 $return = DBA::insert('process', ['pid' => $pid, 'command' => $command, 'created' => DateTimeFormat::utcNow()]);
43 * Remove a process row by pid. If the pid parameter is omitted, we use the current pid
49 public static function deleteByPid($pid = null)
55 return DBA::delete('process', ['pid' => $pid]);
59 * Clean the process table of inactive physical processes
61 public static function deleteInactive()
65 $processes = DBA::select('process', ['pid']);
66 while($process = DBA::fetch($processes)) {
67 if (!posix_kill($process['pid'], 0)) {
68 self::deleteByPid($process['pid']);