top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What is the minimum size of stack is assigned to a process?

+1 vote
529 views

As far as i know when a process is created, 8MB of stack is allocated to it.
Is it right?

If not then is there any fix size or not?

If yes then please answer and Help To solve this question also.

posted Sep 10, 2015 by anonymous

Looking for an answer?  Promote on:
Facebook Share Button Twitter Share Button LinkedIn Share Button

Similar Questions
+4 votes

So many times, we make foreground process to background process in linux system. How does it handle internally ?

+4 votes

Code to write data in to file example.txt.. which is working fine

// basic file operations
#include <iostream>
#include <fstream>
using namespace std;

int main () {
  ofstream myfile;
  myfile.open ("example.txt");
  myfile << "Writing this to a file.\n";
  myfile << "Writing this to a file.\n";
  myfile << "Writing this to a file.\n";
  myfile << "Writing this to a file.\n";
  myfile << "Writing this to a file.\n";
  myfile << "Writing this to a file.\n";
  myfile.close();
  return 0;
}

File : filelimit.c below which takes input as the compiled binary of above code
In this code i am setting the file size limit of process to 10 bytes and the above code is trying to write more than 10 bytes. According to below code if a process is trying to write more than 10 bytes to file it should send the signal SIGXFSZ (see more about this here)

It is not sending here... Why??

#include <stdio.h>
#include <signal.h>
#include <unistd.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>

void handler(int sig)
{
    if(sig == SIGXFSZ)
        printf("Inside handler with correct signal\n");
    else
        printf("Inside handler with wrong signal\n");
}


int main(int argc, char const *argv[])
{
    pid_t pid;
    pid = fork();

    if(pid == 0)
    {
        signal(SIGXFSZ, handler);

        char command[256];
        scanf("%s", command);

        int ret;

        struct rlimit rl;
        rl.rlim_cur = 10;
        rl.rlim_max = 10;
        setrlimit (RLIMIT_FSIZE, &rl);

        char *envp[] = { NULL };
        char *argv[] = { command , NULL };
        ret = execve(command, argv, envp);

        while(1);
    }
    else
    {
        printf("%d - %d\n", getpid(), pid);
        signal(SIGXFSZ, handler);
        while(1);
    }
    return 0;
}
0 votes

Can someone please explain using any example ?

...