2018-05-14 00:59:49 +08:00
|
|
|
/****************************************************************************
|
|
|
|
* include/sys/resource.h
|
|
|
|
*
|
2021-02-03 18:33:49 +08:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you 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
|
2018-05-14 00:59:49 +08:00
|
|
|
*
|
2021-02-03 18:33:49 +08:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2018-05-14 00:59:49 +08:00
|
|
|
*
|
2021-02-03 18:33:49 +08:00
|
|
|
* 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.
|
2018-05-14 00:59:49 +08:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef __INCLUDE_SYS_RESOURCE_H
|
|
|
|
#define __INCLUDE_SYS_RESOURCE_H
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Pre-processor Definitions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/* Possible values of the 'which' argument of getpriority() and
|
|
|
|
* setpriority()
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define PRIO_PROCESS 1 /* 'who' argument is a process ID */
|
|
|
|
#define PRIO_PGRP 2 /* 'who' argument is a process group ID */
|
|
|
|
#define PRIO_USER 3 /* 'who' argument is a user ID */
|
|
|
|
|
|
|
|
/* Possible values of the 'who' parameter of getrusage(): */
|
|
|
|
|
|
|
|
#define RUSAGE_SELF 0 /* Returns information about the current
|
|
|
|
* process */
|
|
|
|
#define RUSAGE_CHILDREN 1 /* Returns information about children of
|
|
|
|
* the current process */
|
|
|
|
|
2020-11-09 12:09:34 +08:00
|
|
|
/* Possible values for the resource argument of getrlimit() and setrlimit() */
|
2018-05-14 00:59:49 +08:00
|
|
|
|
|
|
|
#define RLIMIT_CORE 1 /* Limit on size of core dump file */
|
|
|
|
#define RLIMIT_CPU 2 /* Limit on CPU time per process. */
|
|
|
|
#define RLIMIT_DATA 3 /* Limit on data segment size */
|
|
|
|
#define RLIMIT_FSIZE 4 /* Limit on file size */
|
|
|
|
#define RLIMIT_NOFILE 5 /* Limit on number of open files */
|
|
|
|
#define RLIMIT_STACK 6 /* Limit on stack size */
|
|
|
|
#define RLIMIT_AS 7 /* Limit on address space size */
|
|
|
|
|
|
|
|
/* The following symbolic constants are defined. Each is a value of type
|
|
|
|
* rlim_t.
|
|
|
|
*
|
|
|
|
* On implementations where all resource limits are representable in an
|
|
|
|
* object of type rlim_t, RLIM_SAVED_MAX and RLIM_SAVED_CUR need not be
|
|
|
|
* distinct from RLIM_INFINITY.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define RLIM_INFINITY UINT32_MAX /* No limit */
|
|
|
|
#define RLIM_SAVED_MAX UINT32_MAX /* Unrepresentable saved hard limit */
|
|
|
|
#define RLIM_SAVED_CUR UINT32_MAX /* Unrepresentable saved soft limit */
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Type Definitions
|
|
|
|
****************************************************************************/
|
|
|
|
|
2020-11-09 12:09:34 +08:00
|
|
|
/* All resource limits are represented with this type.
|
|
|
|
* It must be an unsigned integral type.
|
2018-05-14 00:59:49 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
typedef uint32_t rlim_t;
|
|
|
|
|
2018-05-14 02:12:49 +08:00
|
|
|
/* Minimal, compliant rlimit structure */
|
2018-05-14 00:59:49 +08:00
|
|
|
|
|
|
|
struct rlimit
|
|
|
|
{
|
2018-05-14 02:12:49 +08:00
|
|
|
rlim_t rlim_cur; /* The current (soft) limit */
|
|
|
|
rlim_t rlim_max; /* The hard limit */
|
2018-05-14 00:59:49 +08:00
|
|
|
};
|
|
|
|
|
2018-05-14 02:12:49 +08:00
|
|
|
/* Minimal, compliant rusage structure */
|
2018-05-14 00:59:49 +08:00
|
|
|
|
2018-11-09 23:05:48 +08:00
|
|
|
struct rusage
|
2018-05-14 00:59:49 +08:00
|
|
|
{
|
|
|
|
struct timeval ru_utime; /* User time used */
|
|
|
|
struct timeval ru_stime; /* System time used */
|
|
|
|
};
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Public Function Prototypes
|
|
|
|
****************************************************************************/
|
|
|
|
|
2020-09-21 11:50:55 +08:00
|
|
|
#undef EXTERN
|
|
|
|
#if defined(__cplusplus)
|
|
|
|
#define EXTERN extern "C"
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
#else
|
|
|
|
#define EXTERN extern
|
|
|
|
#endif
|
|
|
|
|
2018-05-14 00:59:49 +08:00
|
|
|
int getpriority(int which, id_t who);
|
|
|
|
int getrlimit(int resource, FAR struct rlimit *rlp);
|
|
|
|
int getrusage(int who, FAR struct rusage *r_usage);
|
|
|
|
int setpriority(int which, id_t who, int value);
|
|
|
|
int setrlimit(int resource, FAR const struct rlimit *rlp);
|
|
|
|
|
2020-09-21 11:50:55 +08:00
|
|
|
#undef EXTERN
|
|
|
|
#if defined(__cplusplus)
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2018-05-14 00:59:49 +08:00
|
|
|
#endif /* __INCLUDE_SYS_RESOURCE_H */
|