3 * @file src/Model/Process.php
5 namespace Friendica\Model;
7 use Friendica\BaseObject;
10 require_once 'include/dba.php';
13 * @brief functions for interacting with a process
15 class Process extends BaseObject
18 * Insert a new process row. If the pid parameter is omitted, we use the current pid
20 * @param string $command
24 public static function insert($command, $pid = null)
30 if (!dba::exists('process', ['pid' => getmypid()])) {
31 $return = dba::insert('process', ['pid' => $pid, 'command' => $command, 'created' => datetime_convert()]);
40 * Remove a process row by pid. If the pid parameter is omitted, we use the current pid
45 public static function deleteByPid($pid = null)
51 return dba::delete('process', ['pid' => $pid]);
55 * Clean the process table of inactive physical processes
57 public static function deleteInactive()
61 $processes = dba::select('process', ['pid']);
62 while($process = dba::fetch($processes)) {
63 if (!posix_kill($process['pid'], 0)) {
64 self::deleteByPid($process['pid']);