/* * libslp-sysman * * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. * * Contact: DongGi Jang * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ /** * * @ingroup SLP_PG * @defgroup SLP_PG_SYSMAN System Manager * @{

Introduction

Purpose

The purpose of the document is to describe how applications can use the System Manager APIs. This document gives programming guidelines to application engineers.

Scope

The scope of this document is limited to System Manager API usage.

System Manager Library Overview

Sysman library provides convenience functions to get data about processes or to run processes. It reads the proc file system to check whether a process exists or not, gets a command line and execution path, gets the pid of a process etc. Some APIs of the sysman library use some device files also. If processes which call APIs of sysman library don't have the correct permission, they will fail. Most functions return -1 on failure and the errno will be set.
Please refer the manual pages of proc(Linux Programmer's Manual - PROC(5) http://www.kernel.org/doc/man-pages/man5/proc.5.html) or errno(Linux Programmer's Manual - ERRNO(3) http://www.kernel.org/doc/man-pages/man3/errno.3.html) for more details.

System Manager Funtions

System Manager APIs

API : sysman_get_pid
Parameter In : const char *execpath
Return : int
Functionality : This API is used to get the pid of the process which has the specified execpath.
Internally, this API searches /proc/{pid}/cmdline and compares the parameter execpath with 1st argument of cmdline. If there is no process that has same execpath in /proc/{pid}/cmdline, it will return (-1).

API : sysman_get_cmdline_name
Parameter In : pid_t pid
Parameter Out : char *cmdline
Parameter In : size_t cmdline_size
Return : int
Functionality :This API is used to get the file name in the command line.
Caller process MUST allocate enough memory for the cmdline parameter. Its size should be assigned to cmdline_size.
Internally it reads the 1st argument of /proc/{pid}/cmdline and copies it to cmdline.
The function returns 0 on success and a negative value (-1) on failure.

API : sysman_get_apppath
Parameter In : pid_t pid
Parameter Out : char *app_path
Parameter In : size_t app_path_size
Return : int
Functionality : This API is used to get the execution path of the process specified by the pid parameter.
Caller process MUST allocate enough memory for the app_path parameter. Its size should be assigned to app_path_size.
Internally it reads a link of /proc/{pid}/exe and copies the path to app_path.
The function returns 0 on success and a negative value (-1) on failure.

API : sysconf_set_mempolicy
Parameter In : enum mem_policy mempol
Return : int
Functionality : This API is used to set the policy of the caller process for the situation of low available memory.
The function returns 0 on success and a negative value (-1) on failure.
If the caller process has no permission, it will be failed. Enumerate values @code enum mem_policy { OOM_LIKELY , // For micelloneous applications OOM_NORMAL , // For fundamental applications OOM_IGNORE // For daemon }; @endcode @} **/