Skip to content

Fix async-process.c for OpenBSD #24

Description

@rpx99

O_CLOEXEC used in

int fd = posix_openpt(O_RDWR | O_CLOEXEC | O_NOCTTY);
is not supported in OpenBSD, c.f.: https://man.openbsd.org/posix_openpt

This fixed it for me (recompile with bootstrap and copy like so cp static/amd64/OpenBSD/libasyncprocess.so /usr/local/lib):


static const char* open_pty(int *out_fd)
{
  int fd = posix_openpt(O_RDWR | O_NOCTTY);
  if (fd < 0) return NULL;
  if (fcntl(fd, F_SETFD, FD_CLOEXEC) == -1) {
    close(fd);
    return NULL;
  }
  
  if (grantpt(fd) == -1 || unlockpt(fd) == -1) {
    close(fd);
    return NULL;
  }
  //if (grantpt(fd) == -1 || unlockpt(fd) == -1) return NULL;
  //fcntl(fd, F_SETFD, FD_CLOEXEC);
  const char *name = ptsname(fd);
  if (name == NULL) {
    close(fd);
    return NULL;
  }
  *out_fd = fd;
  return name;
}

Is it possible to change the code please ?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions