summaryrefslogtreecommitdiff
path: root/libc/test/integration/src/spawn/posix_spawn_test_binary.cpp
blob: c1b0cd671da718b555e8435887dd191318444d00 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include "test_binary_properties.h"
#include <string.h>
#include <unistd.h>

int main(int argc, char **argv) {
  if (argc != 1)
    return 5;
  constexpr size_t bufsize = sizeof(TEXT);
  char buf[bufsize];
  ssize_t readsize = bufsize - 1;
  ssize_t len = read(CHILD_FD, buf, readsize);
  if (len != readsize) {
    return 1;
  }
  buf[readsize] = '\0'; // Null terminator
  if (close(CHILD_FD) != 0)
    return 2;
  if (strcmp(buf, TEXT) != 0)
    return 3;
  return 0;
}