From 2893caf8ab0b8428e0b19f15b8e838368e6bcc07 Mon Sep 17 00:00:00 2001 From: Emile Clark-Boman Date: Tue, 9 Sep 2025 19:43:54 +1000 Subject: [PATCH] fix mkpty function declarations --- cli/main.c | 10 ++++++++-- cli/mkpty.c | 2 +- cli/mkpty.h | 8 +++++--- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/cli/main.c b/cli/main.c index 86f4ffd..e2d4986 100644 --- a/cli/main.c +++ b/cli/main.c @@ -1,6 +1,7 @@ -#include "mkpty.h" -#include "sys/types.h" +#include +#include +#include "mkpty.h" // struct d_window { // int ptmx; // fd @@ -16,9 +17,14 @@ int main(int argc, char **argv) { pid_t pid; switch (pid = forkmkpty()) { case -1: + perror("forkmkpty"); break; case 0: + printf("fork: children\n"); + break; default: + printf("fork: parent\n"); break; } + return EXIT_SUCCESS; } diff --git a/cli/mkpty.c b/cli/mkpty.c index 1455f48..4cda39c 100644 --- a/cli/mkpty.c +++ b/cli/mkpty.c @@ -113,7 +113,7 @@ int bindpty(const int fdty) { * forkpty() function. It exists as a learning resource. * REF: https://sourceware.org/git/glibc.git -> ./login/forkpty.c */ -pid_t forkmkpty() { +pid_t forkmkpty(void) { int fdmx, fds; pid_t pid; if (mkpty(&fdmx, &fds)) diff --git a/cli/mkpty.h b/cli/mkpty.h index ed0bce8..a62a27a 100644 --- a/cli/mkpty.h +++ b/cli/mkpty.h @@ -3,10 +3,12 @@ #include -/* Custom implementations of openpty() */ +/* Custom implementation of glibc::openpty() */ int mkpty(int *fdmx, int *fds); -/* Custom implementations of forkpty() */ -pid_t forkmkpty(); +/* Custom implementation of glibc::login_tty() */ +int bindpty(const int fdty); +/* Custom implementation of glibc::forkpty() */ +pid_t forkmkpty(void); int setptsxy(const unsigned short rows, const unsigned short cols, const int fds); int getptsxy(unsigned short *rows, unsigned short *cols, const int fds);