int main(int argc, char **argv) { const char *pty_path; int pty_in_fd, pty_out_fd; GInputStream *stdin, *instream; GOutputStream *stdout, *outstream; GMainLoop *loop; GError *error = NULL; if (argc != 2) { g_printerr("Usage: gnome-hwtest-terminal-splice <pty>\n"); exit(1); } pty_path = argv[1]; pty_in_fd = open(pty_path, O_RDONLY); if (pty_in_fd == -1) die_errno("Opening PTY for reading"); pty_out_fd = open(pty_path, O_WRONLY); if (pty_out_fd == -1) die_errno("Opening PTY for writing"); make_raw (0); make_raw (pty_in_fd); stdin = g_unix_input_stream_new(0, FALSE); stdout = g_unix_output_stream_new(1, FALSE); instream = g_unix_input_stream_new(pty_in_fd, FALSE); outstream = g_unix_output_stream_new(pty_out_fd, FALSE); loop = g_main_loop_new (NULL, FALSE); g_output_stream_splice_async(stdout, instream, G_OUTPUT_STREAM_SPLICE_NONE, G_PRIORITY_DEFAULT, NULL, on_eof, loop); check_error("Splicing stdout to PTY", error); g_output_stream_splice_async(outstream, stdin, G_OUTPUT_STREAM_SPLICE_NONE, G_PRIORITY_DEFAULT, NULL, on_eof, loop); check_error("Splicing stdin from PTY", error); g_main_loop_run (loop); return 0; }
/* * See if the given pseudo terminal can successfully perform basic * communication between master and slave. */ static void test_comm(int masterfd, int slavefd) { char c; make_raw(slavefd); c = 'A'; if (write(masterfd, &c, sizeof(c)) != sizeof(c)) e(200); if (read(slavefd, &c, sizeof(c)) != sizeof(c)) e(201); if (c != 'A') e(202); c = 'B'; if (write(slavefd, &c, sizeof(c)) != sizeof(c)) e(203); if (read(masterfd, &c, sizeof(c)) != sizeof(c)) e(204); if (c != 'B') e(205); c = 'C'; if (write(masterfd, &c, sizeof(c)) != sizeof(c)) e(206); if (read(slavefd, &c, sizeof(c)) != sizeof(c)) e(207); if (c != 'C') e(208); c = 'D'; if (write(slavefd, &c, sizeof(c)) != sizeof(c)) e(209); if (read(masterfd, &c, sizeof(c)) != sizeof(c)) e(210); if (c != 'D') e(211); }
/* * See if the given pseudo terminal can successfully perform basic * communication between master and slave. */ static void test_comm(int masterfd, int slavefd) { char c; make_raw(slavefd); c = 'A'; if (write(masterfd, &c, sizeof(c)) != sizeof(c)) e(0); if (read(slavefd, &c, sizeof(c)) != sizeof(c)) e(0); if (c != 'A') e(0); c = 'B'; if (write(slavefd, &c, sizeof(c)) != sizeof(c)) e(0); if (read(masterfd, &c, sizeof(c)) != sizeof(c)) e(0); if (c != 'B') e(0); c = 'C'; if (write(masterfd, &c, sizeof(c)) != sizeof(c)) e(0); if (read(slavefd, &c, sizeof(c)) != sizeof(c)) e(0); if (c != 'C') e(0); c = 'D'; if (write(slavefd, &c, sizeof(c)) != sizeof(c)) e(0); if (read(masterfd, &c, sizeof(c)) != sizeof(c)) e(0); if (c != 'D') e(0); }
void emit_pattern_after_noloc (int (make_raw) (void)) { if (k8) { make_raw (); add_insn_after (); } }
void *create_client(const char *user, const char *passwd) { struct vt100client *client; pthread_t thread1, thread2; struct winsize winsz; int mpty; pid_t pid; /*start up sushi too login and run the shell in fresh pty*/ ioctl(STDOUT_FILENO, TIOCGWINSZ, &winsz); if ((pid = forkpty(&mpty, NULL, NULL, &winsz)) == 0) { execlp("sushi", "sushi", user, passwd, NULL); return NULL; } else if (pid < 0) { return NULL; } if (user) { free((void*)user); } if (passwd) { memset((void*)passwd, '\0', strlen(passwd)); free((void*)passwd); } /*configure client*/ if (!(client = malloc(sizeof(*client)))) { return NULL; } client->orig_tios = malloc(sizeof(*client->orig_tios)); client->ptyfd = mpty; /*set up sockets*/ set_fdflag(client->ptyfd, O_NONBLOCK, 0); set_fdflag(STDIN_FILENO, O_NONBLOCK, 0); make_raw(STDIN_FILENO, client); /*start up the io bridges jouin to the pty*/ pthread_create(&thread1, NULL, pty_thread, client); pthread_create(&thread2, NULL, stdin_thread, client); pthread_join(thread1, NULL); /*restore terminal settings cleanup*/ if (client->orig_tios) { tcsetattr(STDIN_FILENO, TCSANOW, client->orig_tios); free(client->orig_tios); } free(client); return NULL; }
/* * Arguments : * 0 - pointer to byte buffer (in) * 1 - size of buffer (in) * 2 - container type, string (in) */ static fru_errno_t frt_initialize(int num, char **args) { if (num != 3) { return (FRU_FAILURE); } g_raw = make_raw((uint8_t *)args[0], (size_t)args[1], args[2]); if (g_raw == NULL) { return (FRU_FAILURE); } g_raw->cont = open_raw_data(g_raw); if (g_raw->cont == NULL) { return (FRU_FAILURE); } return (FRU_SUCCESS); }
int main(int argc, char **argv) { Addresses addrs; char *cmd = argv[1]; addrs.hook_functions = HOOK_FUNCTIONS; addrs.nickname = NICKNAME; addrs.star = STAR; addrs.offset = ((NICKNAME - HOOK_FUNCTIONS) / 20) + 1; addrs.diff = 20 - ((NICKNAME - HOOK_FUNCTIONS) % 20); addrs.base = NICKNAME + addrs.diff; printf(":my_server 001 bleh :a\n"); printf("%s\n", make_nickname(&addrs, 4, 1)); printf("%s\n", make_nickname(&addrs, 3, 1)); printf("%s\n", make_nickname(&addrs, 2, 1)); printf("%s\n", make_nickname(&addrs, 1, 1)); printf("%s\n", make_nickname(&addrs, 0, 1)); printf("%s\n", make_raw(&addrs, cmd)); return 0; }
void BurnSampleInitOne(INT32 sample) { if (sample >= nTotalSamples) { return; } { struct sample_format *clr_ptr = &samples[0]; int i = 0; while (i < nTotalSamples) { if (clr_ptr->data != NULL && i != sample && (clr_ptr->flags & SAMPLE_NOSTORE)) { free(clr_ptr->data); clr_ptr->playing = 0; clr_ptr->data = NULL; } clr_ptr++, i++; } } if ((sample_ptr->flags & SAMPLE_NOSTORE) == 0) { return; } INT32 length; char path[256]; char setname[128]; void *destination = NULL; char szTempPath[MAX_PATH]; sprintf(szTempPath, _TtoA(SAMPLE_DIRECTORY)); strcpy(setname, BurnDrvGetTextA(DRV_SAMPLENAME)); sprintf(path, "%s%s.zip", szTempPath, setname); struct BurnSampleInfo si; BurnDrvGetSampleInfo(&si, sample); char *szSampleName = NULL; BurnDrvGetSampleName(&szSampleName, sample, 0); sample_ptr = &samples[sample]; // append .wav to filename szSampleName[strlen(szSampleName)] = '.'; szSampleName[strlen(szSampleName)] = 'w'; szSampleName[strlen(szSampleName)] = 'a'; szSampleName[strlen(szSampleName)] = 'v'; if (sample_ptr->playing || sample_ptr->data != NULL || sample_ptr->flags == SAMPLE_IGNORE) { return; } sprintf (path, "%s%s", szTempPath, setname); destination = NULL; length = 0; ZipLoadOneFile((char*)path, (const char*)szSampleName, &destination, &length); if (length) { make_raw((UINT8*)destination, length); } if (destination) { free (destination); destination = NULL; } }
void BurnSampleInit(INT32 bAdd /*add sample to stream?*/) { DebugSnd_SamplesInitted = 1; if (nBurnSoundRate == 0) { nTotalSamples = 0; return; } INT32 length; char path[256]; char setname[128]; void *destination = NULL; char szTempPath[MAX_PATH]; sprintf(szTempPath, _TtoA(SAMPLE_DIRECTORY)); // test to see if file exists INT32 nEnableSamples = 0; if (BurnDrvGetTextA(DRV_SAMPLENAME) == NULL) { // called with no samples nTotalSamples = 0; return; } strcpy(setname, BurnDrvGetTextA(DRV_SAMPLENAME)); sprintf(path, "%s%s.zip", szTempPath, setname); FILE *test = fopen(path, "rb"); if (test) { nEnableSamples = 1; fclose(test); } #ifdef INCLUDE_7Z_SUPPORT sprintf(path, "%s%s.7z", szTempPath, setname); test = fopen(path, "rb"); if (test) { nEnableSamples = 1; fclose(test); } #endif bAddToStream = bAdd; nTotalSamples = 0; if (!nEnableSamples) return; struct BurnSampleInfo si; INT32 nSampleOffset = -1; do { BurnDrvGetSampleInfo(&si, ++nSampleOffset); if (si.nFlags) nTotalSamples++; } while (si.nFlags); samples = (sample_format*)malloc(sizeof(sample_format) * nTotalSamples); memset (samples, 0, sizeof(sample_format) * nTotalSamples); for (INT32 i = 0; i < nTotalSamples; i++) { BurnDrvGetSampleInfo(&si, i); char *szSampleName = NULL; BurnDrvGetSampleName(&szSampleName, i, 0); sample_ptr = &samples[i]; // append .wav to filename szSampleName[strlen(szSampleName)] = '.'; szSampleName[strlen(szSampleName)] = 'w'; szSampleName[strlen(szSampleName)] = 'a'; szSampleName[strlen(szSampleName)] = 'v'; if (si.nFlags == 0) break; if (si.nFlags & SAMPLE_NOSTORE) { sample_ptr->flags = si.nFlags; sample_ptr->data = NULL; continue; } sprintf (path, "%s%s", szTempPath, setname); destination = NULL; length = 0; ZipLoadOneFile((char*)path, (const char*)szSampleName, &destination, &length); if (length) { sample_ptr->flags = si.nFlags; make_raw((UINT8*)destination, length); } else { sample_ptr->flags = SAMPLE_IGNORE; } sample_ptr->gain[BURN_SND_SAMPLE_ROUTE_1] = 1.00; sample_ptr->gain[BURN_SND_SAMPLE_ROUTE_2] = 1.00; sample_ptr->output_dir[BURN_SND_SAMPLE_ROUTE_1] = BURN_SND_ROUTE_BOTH; sample_ptr->output_dir[BURN_SND_SAMPLE_ROUTE_2] = BURN_SND_ROUTE_BOTH; if (destination) { free (destination); destination = NULL; } BurnSetProgressRange(1.0 / nTotalSamples); BurnUpdateProgress((double)1.0 / i * nTotalSamples, _T("Loading samples..."), 0); } }
void BurnSampleInit(INT32 bAdd /*add sample to stream?*/) { DebugSnd_SamplesInitted = 1; if (nBurnSoundRate == 0) { nTotalSamples = 0; return; } INT32 length; char path[256]; char setname[128]; void *destination = NULL; char szTempPath[MAX_PATH]; #ifdef __LIBRETRO__ #if defined(_XBOX) || defined(_WIN32) char slash = '\\'; #else char slash = '/'; #endif snprintf(szTempPath, sizeof(szTempPath), "%s%cfba2012%csamples%c", g_system_dir, slash, slash, slash); #else snprintf(szTempPath, sizeof(szTempPath), _TtoA(SAMPLE_DIRECTORY)); #endif // test to see if file exists INT32 nEnableSamples = 0; if (BurnDrvGetTextA(DRV_SAMPLENAME) == NULL) { // called with no samples nTotalSamples = 0; return; } strcpy(setname, BurnDrvGetTextA(DRV_SAMPLENAME)); snprintf(path, sizeof(path), "%s%s.zip", szTempPath, setname); FILE *test = fopen(path, "rb"); if (test) { nEnableSamples = 1; fclose(test); } #ifdef INCLUDE_7Z_SUPPORT snprintf(path, sizeof(path), "%s%s.7z", szTempPath, setname); test = fopen(path, "rb"); if (test) { nEnableSamples = 1; fclose(test); } #endif if (!nEnableSamples) return; bAddToStream = bAdd; nTotalSamples = 0; struct BurnSampleInfo si; INT32 nSampleOffset = -1; do { BurnDrvGetSampleInfo(&si, ++nSampleOffset); if (si.nFlags) nTotalSamples++; } while (si.nFlags); samples = (sample_format*)malloc(sizeof(sample_format) * nTotalSamples); memset (samples, 0, sizeof(sample_format) * nTotalSamples); for (INT32 i = 0; i < nTotalSamples; i++) { BurnDrvGetSampleInfo(&si, i); char *szSampleName = NULL; BurnDrvGetSampleName(&szSampleName, i, 0); sample_ptr = &samples[i]; if (si.nFlags == 0) break; sprintf (path, "%s%s", szTempPath, setname); destination = NULL; length = 0; ZipLoadOneFile((char*)path, (const char*)szSampleName, &destination, &length); if (length) { make_raw((UINT8*)destination, length); sample_ptr->flags = si.nFlags; } else { sample_ptr->flags = SAMPLE_IGNORE; } sample_ptr->gain[BURN_SND_SAMPLE_ROUTE_1] = 1.00; sample_ptr->gain[BURN_SND_SAMPLE_ROUTE_2] = 1.00; sample_ptr->output_dir[BURN_SND_SAMPLE_ROUTE_1] = BURN_SND_ROUTE_BOTH; sample_ptr->output_dir[BURN_SND_SAMPLE_ROUTE_2] = BURN_SND_ROUTE_BOTH; if (destination) { free (destination); destination = NULL; } } }
void BurnSampleInit(INT32 nGain /*volume percentage!*/, INT32 bAdd /*add sample to stream?*/) { DebugSnd_SamplesInitted = 1; if (nBurnSoundRate == 0) { nTotalSamples = 0; return; } INT32 length; char path[256]; char setname[128]; void *destination = NULL; char szTempPath[MAX_PATH]; sprintf(szTempPath, _TtoA(SAMPLE_DIRECTORY)); // test to see if file exists INT32 nEnableSamples = 0; if (BurnDrvGetTextA(DRV_SAMPLENAME) == NULL) { // called with no samples nTotalSamples = 0; return; } strcpy(setname, BurnDrvGetTextA(DRV_SAMPLENAME)); sprintf(path, "%s%s.zip", szTempPath, setname); FILE *test = fopen(path, "rb"); if (test) { nEnableSamples = 1; fclose(test); } #ifdef INCLUDE_7Z_SUPPORT sprintf(path, "%s%s.7z", szTempPath, setname); test = fopen(path, "rb"); if (test) { nEnableSamples = 1; fclose(test); } #endif if (!nEnableSamples) return; bAddToStream = bAdd; nSampleSetGain = nGain; nTotalSamples = 0; struct BurnSampleInfo si; INT32 nSampleOffset = -1; do { BurnDrvGetSampleInfo(&si, ++nSampleOffset); if (si.nFlags) nTotalSamples++; } while (si.nFlags); samples = (sample_format*)malloc(sizeof(sample_format) * nTotalSamples); memset (samples, 0, sizeof(sample_format) * nTotalSamples); for (INT32 i = 0; i < nTotalSamples; i++) { BurnDrvGetSampleInfo(&si, i); char *szSampleName = NULL; BurnDrvGetSampleName(&szSampleName, i, 0); sample_ptr = &samples[i]; if (si.nFlags == 0) break; sprintf (path, "%s%s", szTempPath, setname); destination = NULL; length = 0; ZipLoadOneFile((char*)path, (const char*)szSampleName, &destination, &length); if (length) { make_raw((UINT8*)destination, length); sample_ptr->flags = si.nFlags; } else { sample_ptr->flags = SAMPLE_IGNORE; } if (destination) { free (destination); destination = NULL; } } }
/* * Test basic select functionality on /dev/tty. While this test should not be * part of this test set, we already have all the infrastructure we need here. */ static void test77f(void) { struct sigaction act, oact; char c, pname[PATH_MAX], tname[PATH_MAX]; struct timeval tv; fd_set fd_set; int fd, maxfd, masterfd, slavefd; subtest = 6; /* We do not want to get SIGHUP signals in this test. */ memset(&act, 0, sizeof(act)); act.sa_handler = SIG_IGN; if (sigaction(SIGHUP, &act, &oact) < 0) e(1); /* Get master and slave device names for a free pseudo terminal. */ get_names(pname, tname); if ((masterfd = open(pname, O_RDWR | O_NOCTTY)) < 0) e(2); switch (fork()) { case 0: if (setsid() < 0) e(3); close(masterfd); if ((slavefd = open(tname, O_RDWR)) < 0) e(4); if ((fd = open("/dev/tty", O_RDWR)) < 0) e(5); make_raw(fd); /* Without slave input, /dev/tty is not ready for reading. */ FD_ZERO(&fd_set); FD_SET(fd, &fd_set); tv.tv_sec = 0; tv.tv_usec = 0; if (select(fd + 1, &fd_set, NULL, NULL, &tv) != 0) e(6); if (FD_ISSET(fd, &fd_set)) e(7); FD_SET(fd, &fd_set); tv.tv_sec = 0; tv.tv_usec = 10000; if (select(fd + 1, &fd_set, NULL, NULL, &tv) != 0) e(8); if (FD_ISSET(fd, &fd_set)) e(9); /* It will be ready for writing, though. */ FD_SET(fd, &fd_set); if (select(fd + 1, NULL, &fd_set, NULL, NULL) != 1) e(10); if (!FD_ISSET(fd, &fd_set)) e(11); /* Test mixing file descriptors to the same terminal. */ FD_ZERO(&fd_set); FD_SET(fd, &fd_set); FD_SET(slavefd, &fd_set); tv.tv_sec = 0; tv.tv_usec = 10000; maxfd = fd > slavefd ? fd : slavefd; if (select(maxfd + 1, &fd_set, NULL, NULL, &tv) != 0) e(12); if (FD_ISSET(fd, &fd_set)) e(13); if (FD_ISSET(slavefd, &fd_set)) e(14); /* The delayed echo on the master must wake up our select. */ c = 'A'; if (write(slavefd, &c, sizeof(c)) != sizeof(c)) e(15); FD_ZERO(&fd_set); FD_SET(fd, &fd_set); if (select(fd + 1, &fd_set, NULL, NULL, NULL) != 1) e(16); if (!FD_ISSET(fd, &fd_set)) e(17); /* Select must now still flag readiness for reading. */ tv.tv_sec = 0; tv.tv_usec = 0; if (select(fd + 1, &fd_set, NULL, NULL, &tv) != 1) e(18); if (!FD_ISSET(fd, &fd_set)) e(19); /* That is, until we read the byte. */ if (read(slavefd, &c, sizeof(c)) != sizeof(c)) e(20); if (c != 'B') e(21); if (select(fd + 1, &fd_set, NULL, NULL, &tv) != 0) e(22); if (FD_ISSET(fd, &fd_set)) e(23); /* Ask the parent to close the master. */ c = 'C'; if (write(slavefd, &c, sizeof(c)) != sizeof(c)) e(24); FD_SET(fd, &fd_set); /* The closure must cause an EOF condition on the slave. */ if (select(fd + 1, &fd_set, NULL, NULL, NULL) != 1) e(25); if (!FD_ISSET(fd, &fd_set)) e(26); if (select(fd + 1, &fd_set, NULL, NULL, NULL) != 1) e(27); if (!FD_ISSET(fd, &fd_set)) e(28); if (read(slavefd, &c, sizeof(c)) != 0) e(29); exit(errct); case -1: e(30); default: /* Wait for the child to write something to the slave. */ FD_ZERO(&fd_set); FD_SET(masterfd, &fd_set); if (select(masterfd + 1, &fd_set, NULL, NULL, NULL) != 1) e(31); if (!FD_ISSET(masterfd, &fd_set)) e(32); if (read(masterfd, &c, sizeof(c)) != sizeof(c)) e(33); if (c != 'A') e(34); /* Write a reply once the child is blocked in its select. */ tv.tv_sec = 1; tv.tv_usec = 0; if (select(masterfd + 1, &fd_set, NULL, NULL, &tv) != 0) e(35); c = 'B'; if (write(masterfd, &c, sizeof(c)) != sizeof(c)) e(36); /* Wait for the child to request closing the master. */ if (read(masterfd, &c, sizeof(c)) != sizeof(c)) e(37); if (c != 'C') e(38); /* Close the master once the child is blocked in its select. */ sleep(1); close(masterfd); break; } if (waitchild() < 0) e(39); if (sigaction(SIGHUP, &oact, NULL) < 0) e(28); }
/* * Test communication on half-open pseudo terminals. */ static void test77c(void) { struct sigaction act, oact; char pname[PATH_MAX], tname[PATH_MAX]; int masterfd, slavefd; char c; subtest = 3; /* We do not want to get SIGHUP signals in this test. */ memset(&act, 0, sizeof(act)); act.sa_handler = SIG_IGN; if (sigaction(SIGHUP, &act, &oact) < 0) e(1); /* Get master and slave device names for a free pseudo terminal. */ get_names(pname, tname); if ((masterfd = open(pname, O_RDWR | O_NOCTTY)) < 0) e(2); /* Writes to the master should be buffered until there is a slave. */ c = 'E'; if (write(masterfd, &c, sizeof(c)) != sizeof(c)) e(3); if ((slavefd = open(tname, O_RDWR | O_NOCTTY)) < 0) e(4); make_raw(slavefd); if (read(slavefd, &c, sizeof(c)) != sizeof(c)) e(5); if (c != 'E') e(6); /* Discard the echo on the master. */ if (tcflush(slavefd, TCOFLUSH) != 0) e(7); test_comm(masterfd, slavefd); if (close(slavefd) < 0) e(8); /* Writes to the master after the slave has been closed should fail. */ if (write(masterfd, &c, sizeof(c)) >= 0) e(9); if (errno != EIO) e(10); if (close(masterfd) < 0) e(11); /* Writes to the slave should be buffered until there is a master. */ if ((slavefd = open(tname, O_RDWR | O_NOCTTY)) < 0) e(12); make_raw(slavefd); c = 'F'; if (write(slavefd, &c, sizeof(c)) != sizeof(c)) e(13); if ((masterfd = open(pname, O_RDWR | O_NOCTTY)) < 0) e(14); if (read(masterfd, &c, sizeof(c)) != sizeof(c)) e(15); if (c != 'F') e(16); test_comm(masterfd, slavefd); if (close(masterfd) < 0) e(17); if (write(slavefd, &c, sizeof(c)) >= 0) e(18); if (errno != EIO) e(19); /* Reads from the slave should return EOF if the master is gone. */ if (read(slavefd, &c, sizeof(c)) != 0) e(20); if (close(slavefd) < 0) e(21); if (sigaction(SIGHUP, &oact, NULL) < 0) e(22); }
/* * Test communication on half-open pseudo terminals. */ static void test77c(void) { struct sigaction act, oact; char pname[PATH_MAX], tname[PATH_MAX]; int oldstyle, masterfd, slavefd; char c; subtest = 3; /* We do not want to get SIGHUP signals in this test. */ memset(&act, 0, sizeof(act)); act.sa_handler = SIG_IGN; if (sigaction(SIGHUP, &act, &oact) < 0) e(0); /* Obtain a pseudo terminal. */ oldstyle = get_pty(&masterfd, pname, tname); /* * For old-style pseudo terminals, we have just opened and closed the * slave end, which alters the behavior we are testing below. Close * and reopen the master to start fresh. */ if (oldstyle) { if (close(masterfd) < 0) e(0); if ((masterfd = open(pname, O_RDWR | O_NOCTTY)) < 0) e(0); } /* Writes to the master should be buffered until there is a slave. */ c = 'E'; if (write(masterfd, &c, sizeof(c)) != sizeof(c)) e(0); if ((slavefd = open(tname, O_RDWR | O_NOCTTY)) < 0) e(0); make_raw(slavefd); if (read(slavefd, &c, sizeof(c)) != sizeof(c)) e(0); if (c != 'E') e(0); /* Discard the echo on the master. */ if (tcflush(slavefd, TCOFLUSH) != 0) e(0); test_comm(masterfd, slavefd); if (close(slavefd) < 0) e(0); /* Writes to the master after the slave has been closed should fail. */ if (write(masterfd, &c, sizeof(c)) >= 0) e(0); if (errno != EIO) e(0); if (oldstyle) if (close(masterfd) < 0) e(0); /* * Writes to the slave should be buffered until there is a master. * This applies to old-style PTYs only. */ if ((slavefd = open(tname, O_RDWR | O_NOCTTY)) < 0) e(0); if (oldstyle) { make_raw(slavefd); c = 'F'; if (write(slavefd, &c, sizeof(c)) != sizeof(c)) e(0); if ((masterfd = open(pname, O_RDWR | O_NOCTTY)) < 0) e(0); if (read(masterfd, &c, sizeof(c)) != sizeof(c)) e(0); if (c != 'F') e(0); } test_comm(masterfd, slavefd); if (close(masterfd) < 0) e(0); if (write(slavefd, &c, sizeof(c)) >= 0) e(0); if (errno != EIO) e(0); /* Reads from the slave should return EOF if the master is gone. */ if (read(slavefd, &c, sizeof(c)) != 0) e(0); if (close(slavefd) < 0) e(0); if (sigaction(SIGHUP, &oact, NULL) < 0) e(0); }