Stack Size and ulimit. - Linux

This is a discussion on Stack Size and ulimit. - Linux ; Hi All, Apologies if this has been asked before, but, My program is failing with an ENOMEM from pthread_create(). Before unning my program I can issue 'ulimit -s unlimited' to increase the stack size and my program will work. Prior ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: Stack Size and ulimit.

  1. Stack Size and ulimit.

    Hi All,

    Apologies if this has been asked before, but,

    My program is failing with an ENOMEM from pthread_create(). Before
    unning my program I can issue 'ulimit -s unlimited' to increase the
    stack size and my program will work.

    Prior to increasing the stack size I issue ulimit -a and I notice that
    my default stack size is 8192.

    Now, I see that include/linux/resource.h has:
    #define _STK_LIM (8*1024*1024).

    So, I change this to (64*1024*1024) and recompile the kernel. After a
    reboot I see that ulimit -a shows 65536.

    Now, I run my program again, and I still get ENOMEM response from
    pthread_create() !!!!

    My embedded system has 64M of RAM !!!

    So, why does 'ulimit -s unlimited' work and hacking resource.h not
    work?

    What am I missing?

    Also, the secondary question here is? Is hacking the kernel like this
    an acceptable approach? Or should I add the ulimit -s command to a
    setup file somewhere?


    Hope/comments appreciated

    Regards

    Nick

  2. Re: Stack Size and ulimit.

    On Nov 11, 3:32*am, Control Freq
    wrote:

    > So, why does 'ulimit -s unlimited' work and hacking resource.h not
    > work?
    >
    > What am I missing?


    Probably your startup code (whatever launches non-root processes,
    possibly 'init') is changing the stack limit to a reasonable default.

    DS

+ Reply to Thread