mirror of
https://github.com/freebsd/freebsd-src.git
synced 2024-12-02 21:32:58 +00:00
MFstable/11 r309661:
MFC r306962: r306962 (by br): Ensure data in pipe is available to read. Useful for latest (5th, direct mode) test only.
This commit is contained in:
parent
c908b0f57a
commit
295fae79ea
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/stable/10/; revision=309662
@ -26,6 +26,7 @@ SUCH DAMAGE.
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/wait.h>
|
||||
#include <sys/event.h>
|
||||
#include <assert.h>
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
@ -49,10 +50,12 @@ main(void)
|
||||
{
|
||||
char buffer[32768], buffer2[32768], go[] = "go", go2[] = "go2";
|
||||
int desc[2], ipc_coord[2];
|
||||
struct kevent event, ke;
|
||||
ssize_t error;
|
||||
int successes = 0;
|
||||
struct stat status;
|
||||
pid_t new_pid;
|
||||
int kq;
|
||||
|
||||
error = pipe(desc);
|
||||
if (error == -1)
|
||||
@ -118,9 +121,24 @@ main(void)
|
||||
_exit(0);
|
||||
}
|
||||
|
||||
kq = kqueue();
|
||||
if (kq == -1)
|
||||
_exit(1);
|
||||
|
||||
EV_SET(&ke, desc[0], EVFILT_READ, EV_ADD, 0, 0, NULL);
|
||||
|
||||
/* Attach event to the kqueue. */
|
||||
if (kevent(kq, &ke, 1, NULL, 0, NULL) != 0)
|
||||
_exit(2);
|
||||
|
||||
while (successes < 5) {
|
||||
SYNC_W(1, go);
|
||||
SYNC_R(1, go2);
|
||||
|
||||
/* Ensure data is available to read */
|
||||
if (kevent(kq, NULL, 0, &event, 1, NULL) != 1)
|
||||
_exit(3);
|
||||
|
||||
fstat(desc[0], &status);
|
||||
error = read(desc[0], &buffer2, sizeof(buffer2));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user