2019-11-17 15:40:05 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* libs/libc/unistd/lib_getrusage.c
|
|
|
|
*
|
2020-08-22 18:36:57 +02: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
|
2019-11-17 15:40:05 +01:00
|
|
|
*
|
2020-08-22 18:36:57 +02:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2019-11-17 15:40:05 +01:00
|
|
|
*
|
2020-08-22 18:36:57 +02: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.
|
2019-11-17 15:40:05 +01:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <errno.h>
|
|
|
|
|
|
|
|
#include <sys/resource.h>
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Public Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: getrusage
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* The getrusage() function shall provide measures of the resources used
|
|
|
|
* by the current process or its terminated and waited-for child processes.
|
|
|
|
* If the value of the who argument is RUSAGE_SELF, information shall be
|
|
|
|
* returned about resources used by the current process. If the value of
|
|
|
|
* the who argument is RUSAGE_CHILDREN, information shall be returned
|
|
|
|
* about resources used by the terminated and waited-for children of the
|
|
|
|
* current process. If the child is never waited for (for example, if the
|
|
|
|
* parent has SA_NOCLDWAIT set or sets SIGCHLD to SIG_IGN), the resource
|
|
|
|
* information for the child process is discarded and not included in the
|
|
|
|
* resource information provided by getrusage().
|
|
|
|
*
|
2022-07-11 17:11:40 +02:00
|
|
|
* Note: This is currently a dummy implementation and as such does not
|
|
|
|
* honor the 'who' parameter.
|
|
|
|
*
|
2019-11-17 15:40:05 +01:00
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
int getrusage(int who, FAR struct rusage *r_usage)
|
|
|
|
{
|
2022-07-11 17:11:40 +02:00
|
|
|
UNUSED(who);
|
|
|
|
|
2019-11-17 15:40:05 +01:00
|
|
|
if (r_usage == NULL)
|
|
|
|
{
|
|
|
|
set_errno(EINVAL);
|
|
|
|
return ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(r_usage, 0, sizeof(*r_usage));
|
|
|
|
return OK;
|
|
|
|
}
|