common.c revision 6332
961N/A* The contents of this file are subject to the terms of the 961N/A* Common Development and Distribution License, Version 1.0 only 961N/A* (the "License"). You may not use this file except in compliance 961N/A* You can obtain a copy of the license at 961N/A* See the License for the specific language governing permissions 961N/A* and limitations under the License. 961N/A* When distributing Covered Code, include this CDDL HEADER in each 961N/A* file and include the License file at 961N/A* add the following below this CDDL HEADER, with the fields enclosed 961N/A* by brackets "[]" replaced with your own identifying * information: 961N/A* Portions Copyright [yyyy] [name of copyright owner] 5072N/A* Copyright 2008-2010 Sun Microsystems, Inc. 6332N/A* Portions Copyright 2013 ForgeRock AS 961N/A// ---------------------------------------------------- 961N/A// Function used to create a process with the given command. 961N/A// The information about the process is stored in procInfo. 961N/A// The function returns TRUE if the process could be created 961N/A// ---------------------------------------------------- 5072N/A debug(
"createChildProcess: Attempting to create child process '%s' background=%d.",
961N/A // reset process info first 961N/A // initialize handles to pass to the child process 961N/A // Create the child process 5072N/A "createChildProcess: Failed to create child process '%s'. Last error = %d.",
5072N/A debug(
"createBatchFileChildProcess: the batch file path is too long.");
5072N/A debug(
"createBatchFileChildProcess: Attempting to create child process '%s' background=%d.",
5072N/A // reset process info first 5072N/A // initialize handles to pass to the child process 5072N/A // Create the child process 5072N/A "cmd.exe",
// application name 5072N/A debug(
"createBatchFileChildProcess: Successfully created child process '%s'.",
command);
5072N/A debugError(
"createBatchFileChildProcess: Failed to create child process '%s'. Last error = %d.",
961N/A// ---------------------------------------------------- 961N/A// Function used to launch a process for the given command 961N/A// If the process could be created it returns the pid of 961N/A// the created process and -1 otherwise. 961N/A// ---------------------------------------------------- 5072N/A// ---------------------------------------------------- 5072N/A// Function used to wait for a process. 5072N/A// The passed waitTime parameter is maximum the time in milliseconds to wait. 5072N/A// Returns TRUE if the process ended and updates the exitCode 5072N/A// parameter with the return value of the process. 5072N/A// Returns FALSE if the process did not end with the provided 5072N/A// timeout and the error code returned by WaitForSingleObject 5072N/A// in the provided exitCode value. 5072N/A// ---------------------------------------------------- 1298N/A// --------------------------------------------------- 1298N/A// --------------------------------------------------- 1298N/A // The file containing the log. 1878N/A debug(
"--------------- FIRST LOG MESSAGE FROM '%s' ---------------",
1298N/A // It would be nice to echo to stderr, but that doesn't appear to work. 1298N/A// --------------------------------------------------------------- 1298N/A// Get the fully-qualified debug log file name. The logic in this 1298N/A// method assumes that the executable of this process is in a 1298N/A// direct subdirectory of the instance root. 1298N/A// --------------------------------------------------------------- 1298N/A // Get the name of the executable. 1878N/A // Cut everything after the last slash, twice. This will take us back to the 1298N/A // This logic assumes that we are in a directory above the instance root. 6332N/A // Instance root is in execName (eg. C:\opendj 6332N/A // and adds the log's folder name to it 6332N/A // If the log folder doesn's exist in the instance path 6332N/A // we create the log file in the temp directory. 1298N/A// --------------------------------------------------------------- 1298N/A// Function called to know if the --debug option was passed 1298N/A// when calling this executable or not. The DEBUG variable is 1298N/A// --------------------------------------------------------------- 1298N/A// --------------------------------------------------------------- 1298N/A// Deletes a file if it's larger than the given maximum size. 1298N/A// --------------------------------------------------------------- 6332N/A// --------------------------------------------------------------- 6332N/A// Checks if the specifed directory exist. 6332N/A// ---------------------------------------------------------------