From: Caspar Zhang <caspar@casparzhang.com>
To: Garrett Cooper <yanegomi@gmail.com>
Cc: LTP List <ltp-list@lists.sourceforge.net>
Subject: Re: [LTP] [PATCH] sched_getaffinity: fix possible fail in negative case
Date: Fri, 09 Mar 2012 16:59:15 +0800 [thread overview]
Message-ID: <4F59C663.8060508@casparzhang.com> (raw)
In-Reply-To: <1B7D43CE-92E4-4D04-BBEF-97CEE3AB1D69@gmail.com>
On 03/09/2012 03:19 PM, Garrett Cooper wrote:
> 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
I'll keep your test case and remove the getpid()+1 one.
Thanks,
Caspar
------------------------------------------------------------------------------
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
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
next prev parent reply other threads:[~2012-03-09 9:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-09 5:28 [LTP] [PATCH] sched_getaffinity: fix possible fail in negative case Caspar Zhang
2012-03-09 5:48 ` Caspar Zhang
2012-03-09 5:53 ` Wanlong Gao
2012-03-09 7:19 ` Garrett Cooper
2012-03-09 8:59 ` Caspar Zhang [this message]
2012-05-02 12:27 ` Cyril Hrubis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4F59C663.8060508@casparzhang.com \
--to=caspar@casparzhang.com \
--cc=ltp-list@lists.sourceforge.net \
--cc=yanegomi@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox