1 /* system/core/include/logwrap/logwrap.h 2 * 3 * Copyright 2013, The Android Open Source Project 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 #pragma once 19 20 /* 21 * Run a command while logging its stdout and stderr 22 * 23 * Arguments: 24 * argc: the number of elements in argv 25 * argv: an array of strings containing the command to be executed and its 26 * arguments as separate strings. argv does not need to be 27 * NULL-terminated 28 * status: the equivalent child status as populated by wait(status). This 29 * value is only valid when logwrap successfully completes. If NULL 30 * the return value of the child will be the function's return value. 31 * forward_signals: set to true if you want to forward SIGINT, SIGQUIT, and 32 * SIGHUP to the child process, while it is running. You likely do 33 * not need to use this; it is primarily for the logwrapper 34 * executable itself. 35 * log_target: Specify where to log the output of the child, either LOG_NONE, 36 * LOG_ALOG (for the Android system log), LOG_KLOG (for the kernel 37 * log), or LOG_FILE (and you need to specify a pathname in the 38 * file_path argument, otherwise pass NULL). These are bit fields, 39 * and can be OR'ed together to log to multiple places. 40 * abbreviated: If true, capture up to the first 100 lines and last 4K of 41 * output from the child. The abbreviated output is not dumped to 42 * the specified log until the child has exited. 43 * file_path: if log_target has the LOG_FILE bit set, then this parameter 44 * must be set to the pathname of the file to log to. 45 * 46 * Return value: 47 * 0 when logwrap successfully run the child process and captured its status 48 * -1 when an internal error occurred 49 * -ECHILD if status is NULL and the child didn't exit properly 50 * the return value of the child if it exited properly and status is NULL 51 * 52 */ 53 54 /* Values for the log_target parameter logwrap_fork_execvp() */ 55 #define LOG_NONE 0 56 #define LOG_ALOG 1 57 #define LOG_KLOG 2 58 #define LOG_FILE 4 59 60 int logwrap_fork_execvp(int argc, const char* const* argv, int* status, bool forward_signals, 61 int log_target, bool abbreviated, const char* file_path); 62