Date: Tue, 31 Jul 2001 21:24:48 +0200 From: Gabriel Ambuehl <gabriel_ambuehl@buz.ch> To: questions@freebsd.org Subject: select() on a named pipe blocks indefinitely Message-ID: <115350818950.20010731212448@buz.ch>
next in thread | raw e-mail | index | archive | help
-----BEGIN PGP SIGNED MESSAGE----- Hello, I've there got a strange problem with select on a named pipe (FIFO): If I call select() on it without supplying a timeout, the program won't ever return from the select until it's killed. But without select(), I see all the data I cat > FIFO_PATH into the named pipe... { char result[512]; int fifo_des; fd_set rset; mkfifo(FIFO_PATH, (mode_t) (S_IRUSR | S_IWUSR | S_IWGRP)); fifo_des=open((const char *) FIFO_PATH, O_RDONLY|O_NONBLOCK); //blocks if there's no writer on the pipe but as soon as one //opens the pipe, it will return as it should. According to UNPv2 //this is the correct behavior. if (fifo_des < 0) { cout << "fatal error: can't open FIFO" << endl; exit(1); } FD_ZERO(&rset); while(1) { FD_SET(fifo_des, &rset); select(1, &rset, (fd_set *) NULL, (fd_set *) NULL, (struct timeval *) NULL); if(FD_ISSET(fifo_des, &rset)) { read(fifo_des, (void *) &result, (size_t) sizeof(result)); cout << "message: " << result <<endl; } } close(fifo_des); unlink(FIFO_PATH); } What am I doing wrong? TIA & best regards, Gabriel -----BEGIN PGP SIGNATURE----- Version: PGP 6.5i iQEVAwUBO2b3+cZa2WpymlDxAQHEaQgAhYRtXW8CRJtFfoDsSCiyQZm34cWbTLFq 8dFOETAjG2A4HTyymNXoBI0dWHABkpsO273FXLEhQZdHSiWLZ823b9IYQTmg1hCi 7X7kU7JkKmjnO3zyU+ig2gD2dzXCfKf4nP00dSrkz61Tj7EXdj8V1Tg2CO6PA8Mw rT21sS618OFXY8BDAnzshw88DKK0NNSZffVPE8QjS9P5V3EhusXZs3prOov6P7Ls TYmnSk43R11A1mNZsOnKChkU/pKGdwVKBEGzHDnAMWca2Jwch0iHDqce4TCJtCes rMdig6mwMYUf2K0tg5ZG0bY97DuJN/I4MUHrG++Bny0w8qHoVcM1gA== =D8Y4 -----END PGP SIGNATURE----- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?115350818950.20010731212448>