prevent dumping core file?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ken

    prevent dumping core file?

    hello,
    i'm writing a c program on a linux system. i'm debugging a segmentation
    fault but i don't want it to dump a core file because the memory
    footprint of the program is over 300Mb and i don't need it to generate a
    300Mb file every time I add a new printf statement to debug the code.

    can i do something to prevent it from dumping the core file even when it
    seg faults? (is this a unix/linux thing, or a c thing?)

    thanks!
    ken
  • Christopher Benson-Manica

    #2
    Re: prevent dumping core file?

    ken <ken@nospam.com > spoke thus:
    [color=blue]
    > can i do something to prevent it from dumping the core file even when it
    > seg faults? (is this a unix/linux thing, or a c thing?)[/color]

    (It's a *nix thing. comp.unix.progr ammer might be useful.)

    Your post is off-topic for comp.lang.c. Please visit





    for posting guidelines and frequently asked questions. Thank you.

    --
    Christopher Benson-Manica | I *should* know what I'm talking about - if I
    ataru(at)cybers pace.org | don't, I need to know. Flames welcome.

    Comment

    • Joona I Palaste

      #3
      Re: prevent dumping core file?

      ken <ken@nospam.com > scribbled the following:[color=blue]
      > hello,
      > i'm writing a c program on a linux system. i'm debugging a segmentation
      > fault but i don't want it to dump a core file because the memory
      > footprint of the program is over 300Mb and i don't need it to generate a
      > 300Mb file every time I add a new printf statement to debug the code.[/color]
      [color=blue]
      > can i do something to prevent it from dumping the core file even when it
      > seg faults? (is this a unix/linux thing, or a c thing?)[/color]

      It's a Unix/Linux thing.

      --
      /-- Joona Palaste (palaste@cc.hel sinki.fi) ------------- Finland --------\
      \-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
      "Immanuel Kant but Genghis Khan."
      - The Official Graffitist's Handbook

      Comment

      • rahul dev

        #4
        Re: prevent dumping core file?

        Joona I Palaste <palaste@cc.hel sinki.fi> wrote in message news:<buk6ah$4l 0$1@oravannahka .helsinki.fi>.. .[color=blue]
        > ken <ken@nospam.com > scribbled the following:[color=green]
        > > hello,
        > > i'm writing a c program on a linux system. i'm debugging a segmentation
        > > fault but i don't want it to dump a core file because the memory
        > > footprint of the program is over 300Mb and i don't need it to generate a
        > > 300Mb file every time I add a new printf statement to debug the code.[/color]
        >[color=green]
        > > can i do something to prevent it from dumping the core file even when it
        > > seg faults? (is this a unix/linux thing, or a c thing?)[/color]
        >
        > It's a Unix/Linux thing.[/color]

        It is indeed a linux thing. C has nothing to do with dumping a core
        file.
        The linux kernel writes out a file containing a core image of a
        terminated process when certain signals are received. The core image
        file is written
        in the process's working directory. For more information you may
        see the man page of core.
        To prevent it from dumping the core file,you may create a directory
        named
        "core" in your working directory.

        Comment

        • nrk

          #5
          [OT] Re: prevent dumping core file?

          rahul dev wrote:
          [color=blue]
          > Joona I Palaste <palaste@cc.hel sinki.fi> wrote in message
          > news:<buk6ah$4l 0$1@oravannahka .helsinki.fi>.. .[color=green]
          >> ken <ken@nospam.com > scribbled the following:[color=darkred]
          >> > hello,
          >> > i'm writing a c program on a linux system. i'm debugging a segmentation
          >> > fault but i don't want it to dump a core file because the memory
          >> > footprint of the program is over 300Mb and i don't need it to generate
          >> > a 300Mb file every time I add a new printf statement to debug the code.[/color]
          >>[color=darkred]
          >> > can i do something to prevent it from dumping the core file even when
          >> > it seg faults? (is this a unix/linux thing, or a c thing?)[/color]
          >>
          >> It's a Unix/Linux thing.[/color]
          >
          > It is indeed a linux thing. C has nothing to do with dumping a core
          > file.
          > The linux kernel writes out a file containing a core image of a
          > terminated process when certain signals are received. The core image
          > file is written
          > in the process's working directory. For more information you may
          > see the man page of core.[/color]

          I seriously doubt if there's a man page for core on a Linux system.
          [color=blue]
          > To prevent it from dumping the core file,you may create a directory
          > named
          > "core" in your working directory.[/color]

          A better(?) solution is to use the ulimit (bash) or limit (csh/tcsh)
          builtins to set the limit for coredumpsize to 0. To OP: man bash and
          search for ulimit to see how this can be done.

          -nrk.

          --
          Remove devnull for email

          Comment

          • Zoran Cutura

            #6
            Re: prevent dumping core file?

            rahul dev <rahul_dev_agg@ hotmail.com> wrote:[color=blue]
            > To prevent it from dumping the core file,you may create a directory
            > named
            > "core" in your working directory.[/color]

            or simply set "ulimit -c 0" but that would only be the way it
            was meant to be done.

            Comment

            • Michel Bardiaux

              #7
              Re: prevent dumping core file?

              ken wrote:[color=blue]
              > hello,
              > i'm writing a c program on a linux system. i'm debugging a segmentation
              > fault but i don't want it to dump a core file because the memory
              > footprint of the program is over 300Mb and i don't need it to generate a
              > 300Mb file every time I add a new printf statement to debug the code.
              >
              > can i do something to prevent it from dumping the core file even when it
              > seg faults? (is this a unix/linux thing, or a c thing?)
              >
              > thanks!
              > ken[/color]

              'limit core 0' in tcsh, or setrlimit() in the program itself. But
              Murphy's Law is gonna GET you...

              --
              Michel Bardiaux
              Peaktime Belgium S.A. Bd. du Souverain, 191 B-1160 Bruxelles
              Tel : +32 2 790.29.41

              Comment

              • Richard

                #8
                Re: prevent dumping core file?

                michel.bardiaux @peaktime.be wrote...[color=blue]
                > ken wrote:[color=green]
                > > hello,
                > > i'm writing a c program on a linux system. i'm debugging a segmentation
                > > fault but i don't want it to dump a core file because the memory
                > > footprint of the program is over 300Mb and i don't need it to generate a
                > > 300Mb file every time I add a new printf statement to debug the code.
                > >
                > > can i do something to prevent it from dumping the core file even when it
                > > seg faults? (is this a unix/linux thing, or a c thing?)
                > >
                > > thanks!
                > > ken[/color]
                >
                > 'limit core 0' in tcsh, or setrlimit() in the program itself. But
                > Murphy's Law is gonna GET you...[/color]

                'touch ./core ; chmod 000 ./core' trumps Murphy if '.' is the cwd of
                the program dumping core.

                --
                How Americans Can Buy American is an invaluable guide to help patriotic consumers buy products made in American factories by American workers & keep profits and jobs in the USA

                Comment

                • Christopher Benson-Manica

                  #9
                  Re: [OT] Re: prevent dumping core file?

                  nrk <ram_nrk2000@de vnull.verizon.n et> spoke thus:
                  [color=blue]
                  > I seriously doubt if there's a man page for core on a Linux system.[/color]

                  FWIW, the NetBSD system I'm on does have a man page for core, so who
                  knows...?

                  --
                  Christopher Benson-Manica | I *should* know what I'm talking about - if I
                  ataru(at)cybers pace.org | don't, I need to know. Flames welcome.

                  Comment

                  • rahul dev

                    #10
                    Re: [OT] Re: prevent dumping core file?

                    nrk <ram_nrk2000@de vnull.verizon.n et> wrote in message news:<bLqPb.657 9$h77.82@nwrddc 02.gnilink.net> ...[color=blue]
                    > rahul dev wrote:
                    >[color=green]
                    > > Joona I Palaste <palaste@cc.hel sinki.fi> wrote in message
                    > > news:<buk6ah$4l 0$1@oravannahka .helsinki.fi>.. .[color=darkred]
                    > >> ken <ken@nospam.com > scribbled the following:
                    > >> > hello,
                    > >> > i'm writing a c program on a linux system. i'm debugging a segmentation
                    > >> > fault but i don't want it to dump a core file because the memory
                    > >> > footprint of the program is over 300Mb and i don't need it to generate
                    > >> > a 300Mb file every time I add a new printf statement to debug the code.[/color][/color]
                    >[color=green][color=darkred]
                    > >> > can i do something to prevent it from dumping the core file even when
                    > >> > it seg faults? (is this a unix/linux thing, or a c thing?)
                    > >>
                    > >> It's a Unix/Linux thing.[/color]
                    > >
                    > > It is indeed a linux thing. C has nothing to do with dumping a core
                    > > file.
                    > > The linux kernel writes out a file containing a core image of a
                    > > terminated process when certain signals are received. The core image
                    > > file is written
                    > > in the process's working directory. For more information you may
                    > > see the man page of core.[/color]
                    >
                    > I seriously doubt if there's a man page for core on a Linux system.
                    >[color=green]
                    > > To prevent it from dumping the core file,you may create a directory
                    > > named
                    > > "core" in your working directory.[/color]
                    >
                    > A better(?) solution is to use the ulimit (bash) or limit (csh/tcsh)
                    > builtins to set the limit for coredumpsize to 0. To OP: man bash and
                    > search for ulimit to see how this can be done.
                    >
                    > -nrk[/color]

                    Another way is to symbolically link "core" to "/dev/null".
                    For those who don't need to search for ulimit in the man pages.

                    Comment

                    • Dan Pop

                      #11
                      Re: [OT] Re: prevent dumping core file?

                      In <6d1334df.04012 20424.4f8a0edf@ posting.google. com> rahul_dev_agg@h otmail.com (rahul dev) writes:
                      [color=blue]
                      >nrk <ram_nrk2000@de vnull.verizon.n et> wrote in message news:<bLqPb.657 9$h77.82@nwrddc 02.gnilink.net> ...[color=green]
                      >> rahul dev wrote:
                      >>[color=darkred]
                      >> > Joona I Palaste <palaste@cc.hel sinki.fi> wrote in message
                      >> > news:<buk6ah$4l 0$1@oravannahka .helsinki.fi>.. .
                      >> >> ken <ken@nospam.com > scribbled the following:
                      >> >> > hello,
                      >> >> > i'm writing a c program on a linux system. i'm debugging a segmentation
                      >> >> > fault but i don't want it to dump a core file because the memory
                      >> >> > footprint of the program is over 300Mb and i don't need it to generate
                      >> >> > a 300Mb file every time I add a new printf statement to debug the code.[/color]
                      >>[color=darkred]
                      >> >> > can i do something to prevent it from dumping the core file even when
                      >> >> > it seg faults? (is this a unix/linux thing, or a c thing?)
                      >> >>
                      >> >> It's a Unix/Linux thing.
                      >> >
                      >> > It is indeed a linux thing. C has nothing to do with dumping a core
                      >> > file.
                      >> > The linux kernel writes out a file containing a core image of a
                      >> > terminated process when certain signals are received. The core image
                      >> > file is written
                      >> > in the process's working directory. For more information you may
                      >> > see the man page of core.[/color]
                      >>
                      >> I seriously doubt if there's a man page for core on a Linux system.
                      >>[color=darkred]
                      >> > To prevent it from dumping the core file,you may create a directory
                      >> > named
                      >> > "core" in your working directory.[/color]
                      >>
                      >> A better(?) solution is to use the ulimit (bash) or limit (csh/tcsh)
                      >> builtins to set the limit for coredumpsize to 0. To OP: man bash and
                      >> search for ulimit to see how this can be done.[/color]
                      >
                      >Another way is to symbolically link "core" to "/dev/null".
                      >For those who don't need to search for ulimit in the man pages.[/color]

                      That's a stupid solution: not only does it require the link in every
                      directory you use for running programs, but it also doesn't prevent the
                      kernel from generating the code dump, it's just that the core dump gets
                      lost into the bit bucket and the system resources used to generate it are
                      simply wasted.

                      The right thing is the [u]limit builtin command of the modern Unix
                      shells.

                      Dan
                      --
                      Dan Pop
                      DESY Zeuthen, RZ group
                      Email: Dan.Pop@ifh.de

                      Comment

                      Working...