Al's no-double-empty-lines crusade
This commit is contained in:
@@ -22,7 +22,6 @@
|
||||
#include <net/netlib.h>
|
||||
#include <time.h>
|
||||
|
||||
|
||||
#define NUMBER 12
|
||||
|
||||
void main(void) {
|
||||
|
||||
@@ -106,7 +106,6 @@ void main(void) {
|
||||
FD_SET(fd3, &fds_read); /* fd3 => O_WRONLY */
|
||||
FD_SET(fd4, &fds_read); /* fd4 => O_WRONLY */
|
||||
|
||||
|
||||
/* make a select call where none of them are ready (don't use fd5 and fd6) */
|
||||
/* create a timeout as well */
|
||||
timeout.tv_sec = 5;
|
||||
@@ -120,7 +119,6 @@ void main(void) {
|
||||
printf("* Dump RESULTING fds_write:\n");
|
||||
dump_fdset(&fds_write);
|
||||
|
||||
|
||||
/* close and delete dummy files */
|
||||
close(fd1);
|
||||
close(fd2);
|
||||
|
||||
@@ -34,7 +34,6 @@ typedef struct
|
||||
char data[1024];
|
||||
} udp_buffer_t;
|
||||
|
||||
|
||||
int udp_conf(char *host, long port, udp_io_hdr_t *header)
|
||||
{
|
||||
/* configures UDP connection */
|
||||
|
||||
@@ -76,7 +76,6 @@ int udp_conf(long port) {
|
||||
return netfd;
|
||||
}
|
||||
|
||||
|
||||
int main(int argc,char *argv[]) {
|
||||
int fd;
|
||||
ssize_t data_read;
|
||||
|
||||
@@ -37,7 +37,6 @@ typedef struct
|
||||
char data[1024];
|
||||
} udp_buffer_t;
|
||||
|
||||
|
||||
int udp_conf(char *host, long port, udp_io_hdr_t *header)
|
||||
{
|
||||
/* configures UDP connection */
|
||||
@@ -115,7 +114,6 @@ int main(int argc,char *argv[]) {
|
||||
if ((fd = udp_conf(argv[1], PORT, &buffer_send.header) ) < 0)
|
||||
exit(-1);
|
||||
|
||||
|
||||
while (1)
|
||||
{
|
||||
|
||||
|
||||
@@ -76,7 +76,6 @@ int udp_conf(long port) {
|
||||
return netfd;
|
||||
}
|
||||
|
||||
|
||||
int main(int argc,char *argv[]) {
|
||||
int fd;
|
||||
ssize_t data_read;
|
||||
@@ -96,7 +95,6 @@ int main(int argc,char *argv[]) {
|
||||
printf("Waiting for messages on port: %ld\n", PORT);
|
||||
fflush(stdout);
|
||||
|
||||
|
||||
/* get a first message so we know who is the client and we can harass it
|
||||
afterwards */
|
||||
|
||||
|
||||
@@ -80,7 +80,6 @@ int listen(long port) {
|
||||
return netfd;
|
||||
}
|
||||
|
||||
|
||||
int main(int argc,char *argv[]) {
|
||||
int fd;
|
||||
ssize_t data_read;
|
||||
|
||||
@@ -82,7 +82,6 @@ int listen(long port) {
|
||||
return netfd;
|
||||
}
|
||||
|
||||
|
||||
int main(int argc,char *argv[]) {
|
||||
int fd;
|
||||
ssize_t data_read;
|
||||
|
||||
@@ -98,7 +98,6 @@ int listen(long port) {
|
||||
return netfd;
|
||||
}
|
||||
|
||||
|
||||
int main(int argc,char *argv[]) {
|
||||
int fd;
|
||||
ssize_t data_read;
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
|
||||
|
||||
void main(void) {
|
||||
fd_set fds_read, fds_write;
|
||||
int retval;
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
#include <limits.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
void main(void) {
|
||||
fd_set fds_read, fds_write;
|
||||
int retval;
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
*
|
||||
* Ben Gras
|
||||
*/
|
||||
|
||||
#include <time.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
@@ -22,17 +21,12 @@
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include <libutil.h>
|
||||
|
||||
char name[100];
|
||||
|
||||
void pipehandler(int sig)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#define CHILDFD 1
|
||||
#define PARENTFD 0
|
||||
|
||||
void do_child(int pty_fds[])
|
||||
{
|
||||
/* reads from pipe and prints out the data */
|
||||
@@ -41,10 +35,8 @@ void do_child(int pty_fds[])
|
||||
fd_set fds_read;
|
||||
fd_set fds_exception;
|
||||
struct timeval timeout;
|
||||
|
||||
signal(SIGPIPE, pipehandler);
|
||||
signal(SIGUSR1, pipehandler);
|
||||
|
||||
/* first, close the write part, since it is not needed */
|
||||
close(pty_fds[PARENTFD]);
|
||||
|
||||
@@ -83,19 +75,15 @@ void do_child(int pty_fds[])
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void do_parent(int pty_fds[])
|
||||
{
|
||||
char data[1024];
|
||||
int retval;
|
||||
fd_set fds_write;
|
||||
|
||||
signal(SIGPIPE, pipehandler);
|
||||
signal(SIGUSR1, pipehandler);
|
||||
|
||||
/* first, close the read part of pty, since it is not needed */
|
||||
close(pty_fds[CHILDFD]);
|
||||
|
||||
/* now enter a loop of read user input, and writing it to the pty */
|
||||
while (1) {
|
||||
FD_ZERO(&fds_write);
|
||||
@@ -108,7 +96,6 @@ void do_parent(int pty_fds[])
|
||||
fprintf(stderr, "Parent: Error in select\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
printf("Input data: ");
|
||||
if(!gets(data)) {
|
||||
printf("parent: eof; exiting\n");
|
||||
@@ -127,20 +114,17 @@ void do_parent(int pty_fds[])
|
||||
exit(-1);
|
||||
} else printf("wrote %d\n", retval);
|
||||
}
|
||||
|
||||
/* got exit from user */
|
||||
close(pty_fds[PARENTFD]); /* close pty, let child know we're done */
|
||||
wait(&retval);
|
||||
printf("Child exited with status: %d\n", retval);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int ptys[2];
|
||||
int retval;
|
||||
int pid;
|
||||
|
||||
if(openpty(&ptys[0], &ptys[1], name, NULL, NULL) < 0) {
|
||||
perror("openpty");
|
||||
return 1;
|
||||
@@ -151,12 +135,10 @@ int main(int argc, char *argv[])
|
||||
fprintf(stderr, "Error forking\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if (pid == 0) /* child proc */
|
||||
do_child(ptys);
|
||||
else
|
||||
do_parent(ptys);
|
||||
|
||||
/* not reached */
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user