6
#include <sys/socket.h>
11
void sp_handler(int a) {
15
void runparent(pid_t child,int s) {
22
readed=read(s,buf,254);
23
printf("Here %i %i\n",readed,errno);
24
if (readed>0) writed=write(0,buf,readed);
27
// Waiting for child to be finished!
28
waitpid(child,NULL,0);
35
char buf[100]="Helo!\n\0";
41
struct sockaddr mysock;
45
s=socket(PF_UNIX,SOCK_STREAM,0);
47
printf("Error creating socket, error: %i!\n",errno);
51
mysock.sa_family=AF_UNIX;
52
strcpy(mysock.sa_data,"/tmp/ds");
53
if (bind(s,&mysock,3+sizeof("/tmp/ds"))==-1) {
54
printf("Error binding socket to file, error %i!\n",errno);
59
if (child>0) runparent(child,s);
60
else if (child==0) runchild();
61
else printf("Error forking child, error: %i!\n",errno);