* Cannot allocate memory when calling unshare
@ 2013-05-07 5:03 Andy Johnson
2013-05-09 18:26 ` Eric W. Biederman
0 siblings, 1 reply; 4+ messages in thread
From: Andy Johnson @ 2013-05-07 5:03 UTC (permalink / raw)
To: util-linux
Hello,
I use git last update of util-linux.
./unshare -n /bin/bash
works ok.
>From a different terminal I run:
./unshare -p /bin/bash
and get:
bash: fork: Cannot allocate memory
typing:
shows 141 Mb free.
the machine has x86_64 ubuntu, 13.04, Raring Ringtail
any advice ?
Best,
Andy
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Cannot allocate memory when calling unshare
2013-05-07 5:03 Cannot allocate memory when calling unshare Andy Johnson
@ 2013-05-09 18:26 ` Eric W. Biederman
2013-05-10 6:07 ` Andy Johnson
0 siblings, 1 reply; 4+ messages in thread
From: Eric W. Biederman @ 2013-05-09 18:26 UTC (permalink / raw)
To: Andy Johnson; +Cc: util-linux
Andy Johnson <johnsonzjo@gmail.com> writes:
> Hello,
> I use git last update of util-linux.
>
> ./unshare -n /bin/bash
> works ok.
>
> From a different terminal I run:
>
> ./unshare -p /bin/bash
> and get:
> bash: fork: Cannot allocate memory
>
> typing:
> shows 141 Mb free.
>
> the machine has x86_64 ubuntu, 13.04, Raring Ringtail
>
> any advice ?
Pid namespaces are funny. What you are seeing is expected and correct
behavior. The process that calls unshare is not put into the pid
namespace it's first child is. Which means that the first child of bash
becomes the init in the pid namespace and the next child of bash.
The following should do what you want.
unshare --pid -- /bin/sh -c /bin/bash
Eric
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Cannot allocate memory when calling unshare
2013-05-09 18:26 ` Eric W. Biederman
@ 2013-05-10 6:07 ` Andy Johnson
2013-05-10 6:41 ` Eric W. Biederman
0 siblings, 1 reply; 4+ messages in thread
From: Andy Johnson @ 2013-05-10 6:07 UTC (permalink / raw)
To: Eric W. Biederman; +Cc: util-linux
Thanks.
Copy ans paste of that line:
unshare --pid -- /bin/sh -c /bin/bash
still gave:
./unshare --pid -- /bin/sh -c /bin/bash
bash: fork: Cannot allocate memory
also tried to tweak a bit and it did not help
I am using latest git linux-util on fedora 18 with 3.8.4-202.fc18.x86_64 kernel
regards,
Andy
On Thu, May 9, 2013 at 9:26 PM, Eric W. Biederman <ebiederm@xmission.com> wrote:
> Andy Johnson <johnsonzjo@gmail.com> writes:
>
>> Hello,
>> I use git last update of util-linux.
>>
>> ./unshare -n /bin/bash
>> works ok.
>>
>> From a different terminal I run:
>>
>> ./unshare -p /bin/bash
>> and get:
>> bash: fork: Cannot allocate memory
>>
>> typing:
>> shows 141 Mb free.
>>
>> the machine has x86_64 ubuntu, 13.04, Raring Ringtail
>>
>> any advice ?
>
> Pid namespaces are funny. What you are seeing is expected and correct
> behavior. The process that calls unshare is not put into the pid
> namespace it's first child is. Which means that the first child of bash
> becomes the init in the pid namespace and the next child of bash.
>
> The following should do what you want.
> unshare --pid -- /bin/sh -c /bin/bash
>
> Eric
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Cannot allocate memory when calling unshare
2013-05-10 6:07 ` Andy Johnson
@ 2013-05-10 6:41 ` Eric W. Biederman
0 siblings, 0 replies; 4+ messages in thread
From: Eric W. Biederman @ 2013-05-10 6:41 UTC (permalink / raw)
To: Andy Johnson; +Cc: util-linux
Andy Johnson <johnsonzjo@gmail.com> writes:
> Thanks.
> Copy ans paste of that line:
> unshare --pid -- /bin/sh -c /bin/bash
>
> still gave:
> ./unshare --pid -- /bin/sh -c /bin/bash
> bash: fork: Cannot allocate memory
>
> also tried to tweak a bit and it did not help
> I am using latest git linux-util on fedora 18 with
> 3.8.4-202.fc18.x86_64 kernel
How weird. It works here.
My hunch would be that my /bin/sh is dash, and fedora likes to use bash.
It looks like your /bin/sh is exec'ing /bin/bash instead of forking and
execing it. You can look in another window and confirm that you don't
have two processes doing the work only one.
When it works echo $$ returns 1.
Shrug.
Eric
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-05-10 6:42 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-07 5:03 Cannot allocate memory when calling unshare Andy Johnson
2013-05-09 18:26 ` Eric W. Biederman
2013-05-10 6:07 ` Andy Johnson
2013-05-10 6:41 ` Eric W. Biederman
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.