launchd.h 1016 B

12345678910111213141516171819202122232425262728293031323334
  1. // Copyright (c) 2012 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef BASE_MAC_LAUNCHD_H_
  5. #define BASE_MAC_LAUNCHD_H_
  6. #include <launch.h>
  7. #include <sys/types.h>
  8. #include <string>
  9. #include "base/base_export.h"
  10. namespace base {
  11. namespace mac {
  12. // MessageForJob sends a single message to launchd with a simple dictionary
  13. // mapping |operation| to |job_label|, and returns the result of calling
  14. // launch_msg to send that message. On failure, returns NULL. The caller
  15. // assumes ownership of the returned launch_data_t object.
  16. BASE_EXPORT
  17. launch_data_t MessageForJob(const std::string& job_label,
  18. const char* operation);
  19. // Returns the process ID for |job_label| if the job is running, 0 if the job
  20. // is loaded but not running, or -1 on error.
  21. BASE_EXPORT
  22. pid_t PIDForJob(const std::string& job_label);
  23. } // namespace mac
  24. } // namespace base
  25. #endif // BASE_MAC_LAUNCHD_H_