0
0
mirror of https://github.com/termux/termux-packages.git synced 2025-01-19 16:52:16 +00:00
2022-10-15 00:06:00 +03:00

81 lines
1.9 KiB
Diff

diff -uNr ttyrec-1.0.8/ttyrec.c ttyrec-1.0.8/ttyrec.c.patch
--- ttyrec-1.0.8/ttyrec.c 2022-10-14 23:15:59.670392769 +0300
+++ ttyrec-1.0.8/ttyrec.c.patch 2022-10-14 23:25:00.418452092 +0300
@@ -48,12 +48,13 @@
#include <sys/ioctl.h>
#include <sys/time.h>
#include <sys/file.h>
-#include <sys/signal.h>
+#include <signal.h>
#include <stdio.h>
#include <time.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
+#include <sys/wait.h>
#if defined(SVR4)
#include <fcntl.h>
@@ -74,6 +75,35 @@
#include <libutil.h>
#endif
+#ifdef __ANDROID__
+#define HAVE_openpty
+int openpty(int *amaster, int *aslave, char *name, struct termios *termp, struct winsize *winp)
+{
+ char buf[512];
+ int master, slave;
+
+ master = open("/dev/ptmx", O_RDWR);
+ if (master == -1) return -1;
+ if (grantpt(master) || unlockpt(master) || ptsname_r(master, buf, sizeof buf)) goto fail;
+
+ slave = open(buf, O_RDWR | O_NOCTTY);
+ if (slave == -1) goto fail;
+
+ /* XXX Should we ignore errors here? */
+ if (termp) tcsetattr(slave, TCSAFLUSH, termp);
+ if (winp) ioctl(slave, TIOCSWINSZ, winp);
+
+ *amaster = master;
+ *aslave = slave;
+ if (name != NULL) strcpy(name, buf);
+ return 0;
+
+fail:
+ close(master);
+ return -1;
+}
+#endif
+
#if defined(SVR4) && !defined(CDEL)
#if defined(_POSIX_VDISABLE)
#define CDEL _POSIX_VDISABLE
@@ -156,7 +186,7 @@
shell = getenv("SHELL");
if (shell == NULL)
- shell = "/bin/sh";
+ shell = "@TERMUX_PREFIX@/bin/sh";
getmaster();
fixtty();
@@ -203,15 +233,11 @@
void
finish()
{
-#if defined(SVR4)
int status;
-#else /* !SVR4 */
- union wait status;
-#endif /* !SVR4 */
register int pid;
register int die = 0;
- while ((pid = wait3((int *)&status, WNOHANG, 0)) > 0)
+ while ((pid = wait4(-1, (int *)&status, WNOHANG, 0)) > 0)
if (pid == child)
die = 1;