3 * @file src/Model/Process.php
5 namespace Friendica\Model;
7 use Friendica\BaseObject;
10 require_once 'include/dba.php';
11 require_once 'include/datetime.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)
31 if (!dba::exists('process', ['pid' => getmypid()])) {
32 $return = dba::insert('process', ['pid' => $pid, 'command' => $command, 'created' => datetime_convert()]);
41 * Remove a process row by pid. If the pid parameter is omitted, we use the current pid
46 public static function deleteByPid($pid = null)
52 return dba::delete('process', ['pid' => $pid]);
56 * Clean the process table of inactive physical processes
58 public static function deleteInactive()
62 $processes = dba::select('process', ['pid']);
63 while($process = dba::fetch($processes)) {
64 if (!posix_kill($process['pid'], 0)) {
65 self::deleteByPid($process['pid']);