if ((cmpf = malloc(CMSG_LEN(sizeof(int) * 2))) == NULL) err(1, "malloc"); files = (int *)CMSG_DATA(cmpf);
child(int sock){	struct msghdr msg;	char fname[16];	struct cmsghdr *cmp;	int i, fd;	struct sockaddr_un sun;	struct cmsghdr *cmpf;	int *files;	if ((cmpf = malloc(CMSG_LEN(sizeof(int) * 2))) == NULL)		err(1, "malloc");	files = (int *)CMSG_DATA(cmpf);	/*	 * Create socket if needed and connect to the receiver.	 */	if (sock == -1) {		if ((sock = socket(PF_LOCAL, SOCK_STREAM, 0)) == -1)			err(1, "child socket");		(void) memset(&sun, 0, sizeof(sun));		sun.sun_family = AF_LOCAL;		(void) strlcpy(sun.sun_path, SOCK_NAME, sizeof sun.sun_path);		sun.sun_len = SUN_LEN(&sun);		if (connect(sock, (struct sockaddr *)&sun, sizeof(sun)) == -1)			err(1, "child connect");	}	/*	 * Open the files again, and pass them to the child over the socket.	 */	for (i = 0; i < 2; i++) {		(void) snprintf(fname, sizeof fname, "file%d", i + 1);		if ((fd = open(fname, O_RDONLY, 0666)) == -1)			err(1, "child open %s", fname);		files[i] = fd;	}	(void) memset(&msg, 0, sizeof(msg));	msg.msg_control = (caddr_t)cmpf;	msg.msg_controllen = CMSG_LEN(sizeof(int) * 2);	cmp = cmpf;	cmp->cmsg_len = CMSG_LEN(sizeof(int) * 2);	cmp->cmsg_level = SOL_SOCKET;	cmp->cmsg_type = SCM_RIGHTS;	if (sendmsg(sock, &msg, 0))		err(1, "child sendmsg");	/*	 * All done!	 */	exit(0);}