db_process.c 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /* -*- mode:c; c-file-style:"k&r"; c-basic-offset: 4; tab-width:4; indent-tabs-mode:nil; mode:auto-fill; fill-column:78; -*- */
  2. /* vim: set ts=4 sw=4 et tw=78 fo=cqt wm=0: */
  3. /* Copyright (C) 2014 OSCAR lab, Stony Brook University
  4. This file is part of Graphene Library OS.
  5. Graphene Library OS is free software: you can redistribute it and/or
  6. modify it under the terms of the GNU General Public License
  7. as published by the Free Software Foundation, either version 3 of the
  8. License, or (at your option) any later version.
  9. Graphene Library OS is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  15. /*
  16. * db_process.c
  17. *
  18. * This source file contains functions to create a child process and terminate
  19. * the running process. Child does not inherit any objects or memory from its
  20. * parent pricess. A Parent process may not modify the execution of its
  21. * children. It can wait for a child to exit using its handle. Also, parent and
  22. * child may communicate through I/O streams provided by the parent to the child
  23. * at creation.
  24. */
  25. #include "pal_defs.h"
  26. #include "pal.h"
  27. #include "pal_internal.h"
  28. #include "pal_debug.h"
  29. #include "pal_error.h"
  30. #include "api.h"
  31. PAL_HANDLE
  32. DkProcessCreate (PAL_STR uri, PAL_FLG flags, PAL_STR * args)
  33. {
  34. ENTER_PAL_CALL(DkProcessCreate);
  35. log_stream(uri);
  36. PAL_HANDLE handle = NULL;
  37. int ret = _DkProcessCreate(&handle, uri, flags, args);
  38. if (ret < 0) {
  39. _DkRaiseFailure(-ret);
  40. handle = NULL;
  41. }
  42. LEAVE_PAL_CALL_RETURN(handle);
  43. }
  44. void DkProcessExit (PAL_NUM exitcode)
  45. {
  46. ENTER_PAL_CALL(DkProcessExit);
  47. _DkProcessExit(exitcode);
  48. _DkRaiseFailure(PAL_ERROR_NOTKILLABLE);
  49. LEAVE_PAL_CALL();
  50. }
  51. PAL_BOL DkProcessSandboxCreate (PAL_STR manifest, PAL_FLG flags)
  52. {
  53. ENTER_PAL_CALL(DkProcessSandboxCreate);
  54. int ret = _DkProcessSandboxCreate(manifest, flags);
  55. if (ret < 0) {
  56. _DkRaiseFailure(-ret);
  57. LEAVE_PAL_CALL_RETURN(PAL_FALSE);
  58. }
  59. LEAVE_PAL_CALL_RETURN(PAL_TRUE);
  60. }