On Mar 8, 2012, at 9:28 PM, Caspar Zhang wrote:

> 
> in negative case:
> 
>    QUICK_TEST(sched_getaffinity(getpid()+1, len, mask));
> 
> sometimes getpid()+1 will exist if there're other processes running.
> This patch uses a different way to make sure the required pid doesn't
> exist by forking a child and terminating it. The pid of the terminated
> child will not be used for a short time and it's enough for the test to
> continue.

        pid_t is signed on FreeBSD and Linux, so it's safe to assume that a pid 
of -1 won't work. It all depends on what you're trying to achieve (the EINVAL 
or the ESRCH requirement).
        Testing to make sure that a pid isn't running via kill(pid, 0) is 
another semi-viable method, but it's also racy.
Cheers,
-Garrett
------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to