Program Listing for File process.h

Return to documentation for file (include/rcutils/process.h)

// Copyright 2019 Open Source Robotics Foundation, Inc.
//
// Licensed 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.


#ifndef RCUTILS__PROCESS_H_
#define RCUTILS__PROCESS_H_

#ifdef __cplusplus
extern "C"
{
#endif

#if defined _WIN32 || defined __CYGWIN__
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif

#ifndef NOMINMAX
#define NOMINMAX
#endif
// When building with MSVC 19.28.29333.0 on Windows 10 (as of 2020-11-11),
// there appears to be a problem with winbase.h (which is included by
// Windows.h). In particular, warnings of the form:
//
// warning C5105: macro expansion producing 'defined' has undefined behavior
//
// See https://developercommunity.visualstudio.com/content/problem/695656/wdk-and-sdk-are-not-compatible-with-experimentalpr.html
// for more information. For now disable that warning when including windows.h
#pragma warning(push)
#pragma warning(disable : 5105)
#include <Windows.h>
#pragma warning(pop)
#endif

#include "rcutils/allocator.h"
#include "rcutils/macros.h"
#include "rcutils/types/string_array.h"
#include "rcutils/visibility_control.h"


RCUTILS_PUBLIC
RCUTILS_WARN_UNUSED
int rcutils_get_pid(void);


RCUTILS_PUBLIC
RCUTILS_WARN_UNUSED
char * rcutils_get_executable_name(rcutils_allocator_t allocator);

typedef struct rcutils_process_s
{
#if defined _WIN32 || defined __CYGWIN__
  HANDLE handle;
#endif

  int pid;

  rcutils_allocator_t allocator;
} rcutils_process_t;


RCUTILS_PUBLIC
RCUTILS_WARN_UNUSED
rcutils_process_t *
rcutils_start_process(
  const rcutils_string_array_t * args,
  rcutils_allocator_t * allocator);


RCUTILS_PUBLIC
void rcutils_process_close(rcutils_process_t * process);


RCUTILS_PUBLIC
RCUTILS_WARN_UNUSED
rcutils_ret_t
rcutils_process_wait(const rcutils_process_t * process, int * status);

#ifdef __cplusplus
}
#endif

#endif  // RCUTILS__PROCESS_H_