Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
Macros | Typedefs | Functions
exec.cpp File Reference
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/wait.h>
#include <sys/times.h>
#include <sys/stat.h>
#include <sys/types.h>
#include "cmdopt.h"
#include "target.h"
#include "util.h"
#include "exec.h"
Include dependency graph for exec.cpp:

Go to the source code of this file.

Macros

#define SIGHUP   1 /* Linux value */
 
#define SIGQUIT   3 /* Linux value */
 
#define SIGKILL   9 /* Linux value */
 
#define SIGALRM   14 /* Linux value */
 
#define ENOENT   1 /* Linux value */
 
#define ESRCH   3 /* Linux value */
 
#define EINTR   4 /* Linux value */
 
#define ECHILD   10 /* Linux value */
 
#define EINVAL   22 /* Linux value */
 
#define SIGNAL(val)   { SIG ## val, #val }
 

Typedefs

typedef void(* alarm_handler) (int)
 

Functions

int kill (pid_t pid, int sig)
 
FILE * fdopen (int fd, const char *mode)
 
int get_signo (const char *signame)
 
const char * get_signame (int signo)
 
void exec_file (const struct target_opts *options, struct target_status *result)
 

Macro Definition Documentation

◆ ECHILD

#define ECHILD   10 /* Linux value */

Definition at line 102 of file exec.cpp.

◆ EINTR

#define EINTR   4 /* Linux value */

Definition at line 99 of file exec.cpp.

◆ EINVAL

#define EINVAL   22 /* Linux value */

Definition at line 105 of file exec.cpp.

◆ ENOENT

#define ENOENT   1 /* Linux value */

Definition at line 93 of file exec.cpp.

◆ ESRCH

#define ESRCH   3 /* Linux value */

Definition at line 96 of file exec.cpp.

◆ SIGALRM

#define SIGALRM   14 /* Linux value */

Definition at line 88 of file exec.cpp.

◆ SIGHUP

#define SIGHUP   1 /* Linux value */

exec.cpp - Definitions of the child process subsystem

$Id$

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

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.

Definition at line 79 of file exec.cpp.

◆ SIGKILL

#define SIGKILL   9 /* Linux value */

Definition at line 85 of file exec.cpp.

◆ SIGNAL

#define SIGNAL (   val)    { SIG ## val, #val }

Utility macro to generate a signal number/name pair.

@parm val 'short' signal name (no leading SIG) to generate pair for.

See also
signal_names []

Definition at line 158 of file exec.cpp.

◆ SIGQUIT

#define SIGQUIT   3 /* Linux value */

Definition at line 82 of file exec.cpp.

Typedef Documentation

◆ alarm_handler

typedef void(* alarm_handler) (int)

Definition at line 448 of file exec.cpp.

Function Documentation

◆ exec_file()

void exec_file ( const struct target_opts *  options,
struct target_status *  result 
)

Entry point to the child process (watchdog) subsystem.

On UNIX systems, this method fork ()s, creating a child process. This child process becomes a process group leader, redirects input and output files, then exec ()s the target specified in argv [0], providing it with argv to use as its argv array. Meanwhile, the parent process calls the wait_for_child method to monitor the child process, passing the return value back to the calling method.

On Windows, this method creates a process using the windows CreateProcess API call. The startup context for this process is based on the context of the exec utility, but with the standard * file handles redirected. The execution of the process is monitored with the WaitForSingleObject API call. If the process doesn't complete within the allowed timeout, it is then killed. On Windows NT systems, a soft kill of the process (via the GenerateConsoleCtrlEvent API call) are first attempted attempted. The process is then hard killed via the TerminateProcess API call.

Parameters
exec_namename of the child executable
argvargv array for child process
Returns
structure describing how the child procees exited
See also
wait_for_child ()

Definition at line 807 of file exec.cpp.

◆ fdopen()

FILE * fdopen ( int  fd,
const char *  mode 
)

◆ get_signame()

const char * get_signame ( int  signo)

Translates a signal number into a human understandable name

Parameters
signoa signal number
Returns
the human understandable name for the signal (minus the SIG prefix), or "#n" if the the name for the number is unknown to the function, where n is signo
See also
signal_names []

Definition at line 397 of file exec.cpp.

◆ get_signo()

int get_signo ( const char *  signame)

exec.h - Interface declaration for the child process subsystem

$Id$

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

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. Translates a human understandable signal name into a number usable by kill ().

This method understands several formats for signal names. They are as follows:

  • n
  • SIGFOO
  • FOO In this list, n denotes a number and FOO denotes a short signal name.
Parameters
signamea signal name to decode
Returns
the signal number or -1 if a number couldn't be determined
See also
signal_names []

Definition at line 365 of file exec.cpp.

◆ kill()

int kill ( pid_t  pid,
int  sig 
)

Variable Documentation

◆ str

const char* str

Signal name for lookup pair

Definition at line 170 of file exec.cpp.

◆ val

int val

Signal value for lookup pair

Definition at line 169 of file exec.cpp.