3 * @file src/Model/Process.php
5 namespace Friendica\Model;
7 use Friendica\BaseObject;
8 use Friendica\Util\DateTimeFormat;
11 require_once 'include/dba.php';
12 require_once 'include/datetime.php';
15 * @brief functions for interacting with a process
17 class Process extends BaseObject
20 * Insert a new process row. If the pid parameter is omitted, we use the current pid
22 * @param string $command
26 public static function insert($command, $pid = null)
36 if (!dba::exists('process', ['pid' => $pid])) {
37 $return = dba::insert('process', ['pid' => $pid, 'command' => $command, 'created' => DateTimeFormat::utcNow()]);
46 * Remove a process row by pid. If the pid parameter is omitted, we use the current pid
51 public static function deleteByPid($pid = null)
57 return dba::delete('process', ['pid' => $pid]);
61 * Clean the process table of inactive physical processes
63 public static function deleteInactive()
67 $processes = dba::select('process', ['pid']);
68 while($process = dba::fetch($processes)) {
69 if (!posix_kill($process['pid'], 0)) {
70 self::deleteByPid($process['pid']);