Skip to content

ThiagoVinicius/fork_pipe_test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

This illustrates a race condition on CyanogenMod's ADBD (AOSP also).

Compile on linux.

$ gcc fork_pipe_test.c -o fork_pipe_test -lpthread

As this is a race condition, it might not break on the first try, or second, or third. It can, in fact, take a long time to manifest itself. Therefore, run until you get an error:

$ true; while [ $? -eq 0 ]; do echo -----; ./fork_pipe_test; done

If that doesn't stop, edit fork_pipe_test.c, enable FORCE_SMALL_DELAY, and start over. If that's still not enough, enable FORCE_BIG_DELAY instead.

Sample run:

thiago@thiago-laptop:~/fork_pipe_test$ true; while [ $? -eq 0 ]; do echo -----; ./fork_pipe_test; done
-----
Subprocess quit.
All expected data was read.
File descriptor closed.
File descriptor closed.
-----
Subprocess quit.
All expected data was read.
-----
Subprocess quit.
All expected data was read.
File descriptor closed.
File descriptor closed.
-----
Subprocess quit.
File descriptor closed.
Read error: 9
Too few data was read (99907)
thiago@thiago-laptop:~/fork_pipe_test$ 

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages