3 * @file src/Model/Process.php
5 namespace Friendica\Model;
7 use Friendica\BaseObject;
8 use Friendica\Database\DBA;
9 use Friendica\Util\DateTimeFormat;
11 require_once 'include/dba.php';
14 * @brief functions for interacting with a process
16 class Process extends BaseObject
19 * Insert a new process row. If the pid parameter is omitted, we use the current pid
21 * @param string $command
25 public static function insert($command, $pid = null)
35 if (!DBA::exists('process', ['pid' => $pid])) {
36 $return = DBA::insert('process', ['pid' => $pid, 'command' => $command, 'created' => DateTimeFormat::utcNow()]);
45 * Remove a process row by pid. If the pid parameter is omitted, we use the current pid
50 public static function deleteByPid($pid = null)
56 return DBA::delete('process', ['pid' => $pid]);
60 * Clean the process table of inactive physical processes
62 public static function deleteInactive()
66 $processes = DBA::select('process', ['pid']);
67 while($process = DBA::fetch($processes)) {
68 if (!posix_kill($process['pid'], 0)) {
69 self::deleteByPid($process['pid']);