From: Nicolas Dichtel <nicolas.dichtel@6wind.com>
To: Ben Hutchings <bhutchings@solarflare.com>
Cc: shemminger@vyatta.com, netdev@vger.kernel.org, junwei.zhang@6wind.com
Subject: Re: [PATCH iproute2] ipbatch: fix use of 'ip netns exec'
Date: Mon, 08 Jul 2013 11:41:16 +0200 [thread overview]
Message-ID: <51DA893C.8070002@6wind.com> (raw)
In-Reply-To: <1373057353.1913.55.camel@bwh-desktop.uk.level5networks.com>
Le 05/07/2013 22:49, Ben Hutchings a écrit :
> On Fri, 2013-07-05 at 18:05 +0200, Nicolas Dichtel wrote:
>> From: JunweiZhang <junwei.zhang@6wind.com>
>>
>> execvp() does not return when the command succeed, hence all commands in the
>> batch file after the line 'ip netns exec' are not executed.
>>
>> Let's fork before calling execvp().
>
> A Unix shell forks every command it runs, so why should ip do this too?
Just to show the problem:
$ cat test.batch
netns add netns1
netns exec netns1 ip l
netns
$ ip -b test.batch
1: lo: <LOOPBACK> mtu 65536 qdisc noop state DOWN mode DEFAULT
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: sit0: <NOARP> mtu 1480 qdisc noop state DOWN mode DEFAULT
link/sit 0.0.0.0 brd 0.0.0.0
All command after 'netns exec' are never executed.
With the patch:
$ ip -b test.batch
1: lo: <LOOPBACK> mtu 65536 qdisc noop state DOWN mode DEFAULT
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: sit0: <NOARP> mtu 1480 qdisc noop state DOWN mode DEFAULT
link/sit 0.0.0.0 brd 0.0.0.0
netns1
Now, existing netns are displayed.
>
> [...]
>> + return WIFEXITED(status) ? EXIT_SUCCESS : EXIT_FAILURE;
> [...]
>
> So you throw away the original exit code of the child process.
Right, should use WEXITSTATUS(). I will send a v2.
>
> I suspect your actual problem has to do with the exit code of the child,
> and your shell script contains 'set -e'.
Maybe I miss something, but man execvp says:
"The exec() functions only return if an error has have occurred."
next prev parent reply other threads:[~2013-07-08 9:41 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-05 16:05 [PATCH iproute2] ipbatch: fix use of 'ip netns exec' Nicolas Dichtel
2013-07-05 20:49 ` Ben Hutchings
2013-07-08 9:41 ` Nicolas Dichtel [this message]
2013-07-08 13:57 ` Ben Hutchings
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=51DA893C.8070002@6wind.com \
--to=nicolas.dichtel@6wind.com \
--cc=bhutchings@solarflare.com \
--cc=junwei.zhang@6wind.com \
--cc=netdev@vger.kernel.org \
--cc=shemminger@vyatta.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;
as well as URLs for NNTP newsgroup(s).