maximum size of processes with result see in /proc/sys/kernel/pid_max

@param int $id

@return int unsigned
@throws \RuntimeException
960746
private function getSharedItemKey(int $id): int
    {
        if ($id <= 0) {
            throw new \InvalidArgumentException('ID cannot be less or equals zero');
        }

        $st = @stat(__FILE__);
        if (!$st) {
            return -1;
        }

        //@TODO collisions? need more unique key
        $key = (int)sprintf("%u",
            (
                ($st['ino'] & 0xffff) |
                (($st['dev'] & 0xff) << 16) |
                (($id & 0xff) << 24)
            )
        );

        return $key;
    }
140288
public function deleteByIntId(int $id, string $key = null): int
    {
        return $this->deleteByKey($id, $key);
    }
234162
public function delete_bit(string $id): ?int
  {
    if ( \bbn\str::is_uid($id) ){
      return $this->db->delete($this->class_cfg['tables']['user_options_bits'], [
        $this->class_cfg['arch']['user_options_bits']['id'] => $id
      ]);
    }
    return null;
  }
994656
public function deleteById($id) : int
    {
        $sql = 'DELETE FROM `' . $this->table . '` WHERE ';

        // Assign ids
        if (is_array($id)) {
            $i = 0;
            foreach ($id as $_id) {
                if ($i === 0) {
                    $sql .= ' id=:id' . $i;
                } else {
                    $sql .= ' OR id=:id' . $i;
                }
                $i++;
            }
            $query = $this->pdo->prepare($sql);
            for ($j = 0; $j < 0; $j++) {
                $query->bindParam(':id' . $j, $id[$j]);
            }
        } else {
            $sql .= 'id=:id';
            $query = $this->pdo->prepare($sql);
            $query->bindParam(':id', $id);
        }

        $query->execute();

        return $query->rowCount();
    }
468884
public function getCalculation($id)
    {
        if ($this->calculations === null) {
            $this->execute();
        }

        return isset($this->calculations[$id]) ? $this->calculations[$id] : null;
    }
1359374
public function removeElementFromTrash($id)
    {
        try {
            return $this->innerGateway->removeElementFromTrash($id);
        } catch (DBALException $e) {
            throw new RuntimeException('Database error', 0, $e);
        } catch (PDOException $e) {
            throw new RuntimeException('Database error', 0, $e);
        }
    }
369649
public function deleteByStringId(string $id, string $key = null): int
    {
        return $this->deleteByKey($id, $key);
    }
1326851
public function delete(int $id)
    {
        $this->cache->tags($this->getModel())->flush();
        return $this->repository->delete($id);
    }
194638
protected function deleteByKey($id, string $key = null): int
    {
        $key = empty($key) ? $this->repository->getModel()->getKeyName() : $key;

        $row = 0;

        try {
            $row = $this->queryRelate->whereIn($key, (array) $id)->getQuery()->delete();
        } catch (\RuntimeException $exception) {
            throw new ResourceDeleteException($exception->getMessage(), $exception->getCode(), $exception);
        } finally {
            $this->resetQueryRelate();
        }

        return $row;
    }
463977
public function position(string $id): int
    {
        $i = 0;
        foreach ($this->all() as $item) {
            if ($item->id() === $id) {
                return $i;
            }

            ++$i;
        }

        return $this->notFound($id);
    }
787609
protected function check4details($id)
    {
        $objC4D = \Database::getInstance()->prepare("SELECT count(`id`)  AS num
                                                     FROM `tl_dlstatdets`
                                                     WHERE `pid`=?")
                                          ->execute($id);
        return $objC4D->num;
    }
918694
public function getById($id)
    {
        $id = (int) $id;
        $rowSet = $this->getTableGateway()->select([$this->getPrimaryKey() => $id]);
        $row = $rowSet->current();
        return $row;
    }
466401
public function canDeleteLanguage($id)
    {
        try {
            return $this->innerGateway->canDeleteLanguage($id);
        } catch (DBALException $e) {
            throw new RuntimeException('Database error', 0, $e);
        } catch (PDOException $e) {
            throw new RuntimeException('Database error', 0, $e);
        }
    }
218013
public function getMaxUid()
    {

        try {
            $result = app('db')->select("select max(uid) uid from " . config("database.pgsql_workers"));

        } catch (\Exception $e) {
            Log::info('c=CopydataApiController f=getMaxUid  msg=' . $e->getMessage());
            return false;
        }
        $max = $result[0]->uid;
        return (int)$max;
    }
531409
public static function run($id): bool
    {
        $id = abs((int)$id);
        /** @var ServiceEntity $service_entity */
        $service_entity = ServiceEntityRepository::findOneEntityById($id);

        if (!$service_entity || $service_entity->getRunning()) {
            return false;
        }

        $file = Finder::getInstance()->searchForRealPath($service_entity->getFile() . '.php', Finder::TYPE_SERVICES);

        if (!$file || !\file_exists(DIR_BASE . $file)) {
            return false;
        }

        $service_entity->setRunning(1);
        $service_entity->save();

        // No bckground processes
        if (!function_exists('pcntl_fork')) {
            // Run service file
            require DIR_BASE . $file;
            // Set service is done
            self::setDone($id);

            return true;
        }

        // Run as background process
        $pid = pcntl_fork();
        SQL::getInstance()->connect();

        if ($pid == -1) {
            echo $pid . ": Could not start background service for " . $file . "\n";
            // Could not fork
        } else if ($pid) {
            // We are the parent, doing nothing
        } else {
            echo "Running ". $file . "\n";
            // Run service file
            require DIR_BASE . $file;
            // Set service is done
            self::setDone($id);
            exit("Finished ". $file . "\n");
        }

        return true;
    }
491601
public function loadPathData($id)
    {
        try {
            return $this->innerGateway->loadPathData($id);
        } catch (DBALException $e) {
            throw new \RuntimeException('Database error', 0, $e);
        } catch (PDOException $e) {
            throw new \RuntimeException('Database error', 0, $e);
        }
    }
20558
public function find(int $id)
    {
        return $this->cache->tags($this->getModel())->remember($id, 60, function () use ($id) {
            return $this->repository->find($id);
        });
    }