core dump

Hi All,

Fedora 30
rakudo-0.2019.03-2.fc30.x86_64

I have a weird question.  I need to simulate a core
dump under a bash (ulimit) shell.

Any of you guys know who to get Perl to crash with a
core dump?

I need to prove that core dumps are not
active on my system.  Or if I am mistaken.


Many thanks,
-T

-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When we ask for advice, we are usually looking for an accomplice.
    --  Charles Varlet de La Grange
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0
perl6
8/9/2019 10:41:46 PM
perl.perl6.users 1235 articles. 0 followers. Follow

3 Replies
38 Views

Similar Articles

[PageSpeed] 1

On 8/9/19 3:41 PM, ToddAndMargo via perl6-users wrote:
> Hi All,
>=20
> Fedora 30
> rakudo-0.2019.03-2.fc30.x86_64
>=20
> I have a weird question.=C2=A0 I need to simulate a core
> dump under a bash (ulimit) shell.
>=20
> Any of you guys know who to get Perl to crash with a
> core dump?
>=20
> I need to prove that core dumps are not
> active on my system.=C2=A0 Or if I am mistaken.
>=20
>=20
> Many thanks,
> -T
>=20

Follow up:

      To trigger a core dump:
          $ kill -s SIGSEGV PID     Subsitute your PID
          $ kill -s SIGSEGV $$      Will kill your current shell


Since core dumps have changed significantly under Fedora 30
(systemd), anyone wants my full notes, please ping me
on the subject line and respond on this thread.

-T
0
perl6
8/31/2019 12:21:30 AM
--_000_SN6PR09MB3790BB48BC80A9B64DF312B0C0B90SN6PR09MB3790namp_
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

On my box, man core shows how to dump core using ctrl-backslash
$ perl
^\Quit (core dumped)

It also gives the example of creating a pipeline for core handling (.c file=
 text below):
        $ cc -o core_pattern_pipe_test core_pattern_pipe_test.c
           $ su
           Password:
           # echo "|$PWD/core_pattern_pipe_test %p UID=3D%u GID=3D%g sig=3D=
%s" > \
               /proc/sys/kernel/core_pattern
           # exit
           $ sleep 100
           ^\                     # type control-backslash
           Quit (core dumped)
           $ cat core.info
           argc=3D5
           argc[0]=3D</home/mtk/core_pattern_pipe_test>
           argc[1]=3D<20575>
           argc[2]=3D<UID=3D1000>
           argc[3]=3D<GID=3D100>
           argc[4]=3D<sig=3D3>
           Total bytes in core dump: 282624

I used just
$ perl
^\Quit (core dumped)
$ cat core.info
argc=3D5
argc[0]=3D</usr/local/bin/core_pipe_test>
argc[1]=3D<3804>
argc[2]=3D<UID=3D1000>
argc[3]=3D<GID=3D1000>
argc[4]=3D<sig=3D3>
Total bytes in core dump: 602112


  /* core_pattern_pipe_test.c */

       #define _GNU_SOURCE
       #include <sys/stat.h>
       #include <fcntl.h>
       #include <limits.h>
       #include <stdio.h>
       #include <stdlib.h>
       #include <unistd.h>

       #define BUF_SIZE 1024

       int
       main(int argc, char *argv[])
       {
           int tot, j;
           ssize_t nread;
           char buf[BUF_SIZE];
           FILE *fp;
           char cwd[PATH_MAX];

           /* Change our current working directory to that of the
              crashing process */

           snprintf(cwd, PATH_MAX, "/proc/%s/cwd", argv[1]);
           chdir(cwd);

           /* Write output to file "core.info" in that directory */

           fp =3D fopen("core.info", "w+");
           if (fp =3D=3D NULL)
               exit(EXIT_FAILURE);

           /* Display command-line arguments given to core_pattern
              pipe program */

           fprintf(fp, "argc=3D%d\n", argc);
           for (j =3D 0; j < argc; j++)
               fprintf(fp, "argc[%d]=3D<%s>\n", j, argv[j]);

           /* Count bytes in standard input (the core dump) */

           tot =3D 0;
           while ((nread =3D read(STDIN_FILENO, buf, BUF_SIZE)) > 0)
               tot +=3D nread;
           fprintf(fp, "Total bytes in core dump: %d\n", tot);

           fclose(fp);
           exit(EXIT_SUCCESS);
       }

________________________________
From: ToddAndMargo via perl6-users <perl6-users@perl.org>
Sent: Friday, August 30, 2019 7:21 PM
To: perl6-users@perl.org <perl6-users@perl.org>
Subject: Re: core dump

On 8/9/19 3:41 PM, ToddAndMargo via perl6-users wrote:
> Hi All,
>
> Fedora 30
> rakudo-0.2019.03-2.fc30.x86_64
>
> I have a weird question.  I need to simulate a core
> dump under a bash (ulimit) shell.
>
> Any of you guys know who to get Perl to crash with a
> core dump?
>
> I need to prove that core dumps are not
> active on my system.  Or if I am mistaken.
>
>
> Many thanks,
> -T
>

Follow up:

      To trigger a core dump:
          $ kill -s SIGSEGV PID     Subsitute your PID
          $ kill -s SIGSEGV $$      Will kill your current shell


Since core dumps have changed significantly under Fedora 30
(systemd), anyone wants my full notes, please ping me
on the subject line and respond on this thread.

-T

--_000_SN6PR09MB3790BB48BC80A9B64DF312B0C0B90SN6PR09MB3790namp_
Content-Type: text/html; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

<html>
<head>
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dus-ascii"=
>
<style type=3D"text/css" style=3D"display:none;"> P {margin-top:0;margin-bo=
ttom:0;} </style>
</head>
<body dir=3D"ltr">
<div style=3D"font-family: &quot;Times New Roman&quot;, Times, serif; font-=
size: 12pt; color: rgb(0, 0, 0);">
On my box, man core shows how to dump core using ctrl-backslash</div>
<div style=3D"font-family: &quot;Times New Roman&quot;, Times, serif; font-=
size: 12pt; color: rgb(0, 0, 0);">
<span>$ perl<br>
</span>
<div>^\Quit (core dumped)<br>
</div>
<div><br>
</div>
<div><span style=3D"color: rgb(0, 0, 0); font-family: &quot;Times New Roman=
&quot;, Times, serif; font-size: 12pt;">It&nbsp;</span><span style=3D"color=
: rgb(0, 0, 0); font-family: &quot;Times New Roman&quot;, Times, serif; fon=
t-size: 12pt;">also gives the example of creating a pipeline
 for core handling (.c file text below):</span><br>
</div>
</div>
<div style=3D"font-family: &quot;Times New Roman&quot;, Times, serif; font-=
size: 12pt; color: rgb(0, 0, 0);">
<span>&nbsp; &nbsp; &nbsp; &nbsp; $ cc -o core_pattern_pipe_test core_patte=
rn_pipe_test.c<br>
</span>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$ su<br>
</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Password:<br>
</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# echo &quot;|$PWD/core_patte=
rn_pipe_test %p UID=3D%u GID=3D%g sig=3D%s&quot; &gt; \<br>
</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/proc/sys/kerne=
l/core_pattern<br>
</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# exit<br>
</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$ sleep 100<br>
</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;^\ &nbsp; &nbsp; &nbsp; &nbsp=
; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # type control-backslash<br>
</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Quit (core dumped)<br>
</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$ cat core.info<br>
</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;argc=3D5<br>
</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;argc[0]=3D&lt;/home/mtk/core_=
pattern_pipe_test&gt;<br>
</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;argc[1]=3D&lt;20575&gt;<br>
</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;argc[2]=3D&lt;UID=3D1000&gt;<=
br>
</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;argc[3]=3D&lt;GID=3D100&gt;<b=
r>
</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;argc[4]=3D&lt;sig=3D3&gt;<br>
</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Total bytes in core dump: 282=
624<br>
</div>
<span></span><br>
</div>
<div style=3D"font-family: &quot;Times New Roman&quot;, Times, serif; font-=
size: 12pt; color: rgb(0, 0, 0);">
I used just&nbsp;</div>
<div style=3D"font-family: &quot;Times New Roman&quot;, Times, serif; font-=
size: 12pt; color: rgb(0, 0, 0);">
<div>$ perl<br>
</div>
<div>^\Quit (core dumped)<br>
</div>
<div>$ cat core.info<br>
</div>
<div>argc=3D5<br>
</div>
<div>argc[0]=3D&lt;/usr/local/bin/core_pipe_test&gt;<br>
</div>
<div>argc[1]=3D&lt;3804&gt;<br>
</div>
<div>argc[2]=3D&lt;UID=3D1000&gt;<br>
</div>
<div>argc[3]=3D&lt;GID=3D1000&gt;<br>
</div>
<div>argc[4]=3D&lt;sig=3D3&gt;<br>
</div>
<div>Total bytes in core dump: 602112<br>
</div>
<span></span><br>
</div>
<div style=3D"font-family: &quot;Times New Roman&quot;, Times, serif; font-=
size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style=3D"font-family: &quot;Times New Roman&quot;, Times, serif; font-=
size: 12pt; color: rgb(0, 0, 0);">
<span>&nbsp; /* core_pattern_pipe_test.c */<br>
</span>
<div><br>
</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp;#define _GNU_SOURCE<br>
</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp;#include &lt;sys/stat.h&gt;<br>
</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp;#include &lt;fcntl.h&gt;<br>
</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp;#include &lt;limits.h&gt;<br>
</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp;#include &lt;stdio.h&gt;<br>
</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp;#include &lt;stdlib.h&gt;<br>
</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp;#include &lt;unistd.h&gt;<br>
</div>
<div><br>
</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp;#define BUF_SIZE 1024<br>
</div>
<div><br>
</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp;int<br>
</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp;main(int argc, char *argv[])<br>
</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp;{<br>
</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;int tot, j;<br>
</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ssize_t nread;<br>
</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;char buf[BUF_SIZE];<br>
</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;FILE *fp;<br>
</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;char cwd[PATH_MAX];<br>
</div>
<div><br>
</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/* Change our current working=
 directory to that of the<br>
</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; crashing process */<b=
r>
</div>
<div><br>
</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;snprintf(cwd, PATH_MAX, &quot=
;/proc/%s/cwd&quot;, argv[1]);<br>
</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;chdir(cwd);<br>
</div>
<div><br>
</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/* Write output to file &quot=
;core.info&quot; in that directory */<br>
</div>
<div><br>
</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fp =3D fopen(&quot;core.info&=
quot;, &quot;w&#43;&quot;);<br>
</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (fp =3D=3D NULL)<br>
</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;exit(EXIT_FAILU=
RE);<br>
</div>
<div><br>
</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/* Display command-line argum=
ents given to core_pattern<br>
</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pipe program */<br>
</div>
<div><br>
</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fprintf(fp, &quot;argc=3D%d\n=
&quot;, argc);<br>
</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;for (j =3D 0; j &lt; argc; j&=
#43;&#43;)<br>
</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fprintf(fp, &qu=
ot;argc[%d]=3D&lt;%s&gt;\n&quot;, j, argv[j]);<br>
</div>
<div><br>
</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/* Count bytes in standard in=
put (the core dump) */<br>
</div>
<div><br>
</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;tot =3D 0;<br>
</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;while ((nread =3D read(STDIN_=
FILENO, buf, BUF_SIZE)) &gt; 0)<br>
</div>
<span></span><span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;t=
ot &#43;=3D nread;<br>
</span>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fprintf(fp, &quot;Total bytes=
 in core dump: %d\n&quot;, tot);<br>
</div>
<div><br>
</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fclose(fp);<br>
</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;exit(EXIT_SUCCESS);<br>
</div>
<div>&nbsp; &nbsp; &nbsp; &nbsp;}<br>
</div>
<span></span><br>
</div>
<div id=3D"appendonsend"></div>
<hr style=3D"display:inline-block;width:98%" tabindex=3D"-1">
<div id=3D"divRplyFwdMsg" dir=3D"ltr"><font face=3D"Calibri, sans-serif" st=
yle=3D"font-size:11pt" color=3D"#000000"><b>From:</b> ToddAndMargo via perl=
6-users &lt;perl6-users@perl.org&gt;<br>
<b>Sent:</b> Friday, August 30, 2019 7:21 PM<br>
<b>To:</b> perl6-users@perl.org &lt;perl6-users@perl.org&gt;<br>
<b>Subject:</b> Re: core dump</font>
<div>&nbsp;</div>
</div>
<div class=3D"BodyFragment"><font size=3D"2"><span style=3D"font-size:11pt;=
">
<div class=3D"PlainText">On 8/9/19 3:41 PM, ToddAndMargo via perl6-users wr=
ote:<br>
&gt; Hi All,<br>
&gt; <br>
&gt; Fedora 30<br>
&gt; rakudo-0.2019.03-2.fc30.x86_64<br>
&gt; <br>
&gt; I have a weird question.&nbsp; I need to simulate a core<br>
&gt; dump under a bash (ulimit) shell.<br>
&gt; <br>
&gt; Any of you guys know who to get Perl to crash with a<br>
&gt; core dump?<br>
&gt; <br>
&gt; I need to prove that core dumps are not<br>
&gt; active on my system.&nbsp; Or if I am mistaken.<br>
&gt; <br>
&gt; <br>
&gt; Many thanks,<br>
&gt; -T<br>
&gt; <br>
<br>
Follow up:<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; To trigger a core dump:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $ kill -s SIGSEGV PI=
D&nbsp;&nbsp;&nbsp;&nbsp; Subsitute your PID<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $ kill -s SIGSEGV $$=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Will kill your current shell<br>
<br>
<br>
Since core dumps have changed significantly under Fedora 30<br>
(systemd), anyone wants my full notes, please ping me<br>
on the subject line and respond on this thread.<br>
<br>
-T<br>
</div>
</span></font></div>
</body>
</html>

--_000_SN6PR09MB3790BB48BC80A9B64DF312B0C0B90SN6PR09MB3790namp_--
0
Andy_Bach
9/3/2019 4:08:40 PM
>> *From:* ToddAndMargo via perl6-users <perl6-users@perl.org>
>> *Sent:* Friday, August 30, 2019 7:21 PM
>> *To:* perl6-users@perl.org <perl6-users@perl.org>
>> *Subject:* Re: core dump
>> On 8/9/19 3:41 PM, ToddAndMargo via perl6-users wrote:
>>> Hi All,
>>>=20
>>> Fedora 30
>>> rakudo-0.2019.03-2.fc30.x86_64
>>>=20
>>> I have a weird question.  I need to simulate a core
>>> dump under a bash (ulimit) shell.
>>>=20
>>> Any of you guys know who to get Perl to crash with a
>>> core dump?
>>>=20
>>> I need to prove that core dumps are not
>>> active on my system.  Or if I am mistaken.
>>>=20
>>>=20
>>> Many thanks,
>>> -T
>>>=20
>>=20
>> Follow up:
>>=20
>>        To trigger a core dump:
>>            $ kill -s SIGSEGV PID     Subsitute your PID
>>            $ kill -s SIGSEGV $$      Will kill your current shell
>>=20
>>=20
>> Since core dumps have changed significantly under Fedora 30
>> (systemd), anyone wants my full notes, please ping me
>> on the subject line and respond on this thread.
>>=20
>> -T


On 9/3/19 9:08 AM, Andy Bach wrote:
> On my box, man core shows how to dump core using ctrl-backslash
> $ perl
> ^\Quit (core dumped)
>=20
> It also gives the example of creating a pipeline for core handling (.c =

> file text below):
>  =C2=A0 =C2=A0 =C2=A0 =C2=A0 $ cc -o core_pattern_pipe_test core_patter=
n_pipe_test.c
>  =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0$ su
>  =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Password:
>  =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0# echo "|$PWD/core_pattern_pi=
pe_test %p UID=3D%u GID=3D%g=20
> sig=3D%s" > \
>  =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0/proc/sys/kerne=
l/core_pattern
>  =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0# exit
>  =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0$ sleep 100
>  =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0^\ =C2=A0 =C2=A0 =C2=A0 =C2=A0=
 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 # type control-backslash
>  =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Quit (core dumped)
>  =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0$ cat core.info
>  =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0argc=3D5
>  =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0argc[0]=3D</home/mtk/core_pat=
tern_pipe_test>
>  =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0argc[1]=3D<20575>
>  =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0argc[2]=3D<UID=3D1000>
>  =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0argc[3]=3D<GID=3D100>
>  =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0argc[4]=3D<sig=3D3>
>  =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Total bytes in core dump: 282=
624
>=20
> I used just
> $ perl
> ^\Quit (core dumped)
> $ cat core.info
> argc=3D5
> argc[0]=3D</usr/local/bin/core_pipe_test>
> argc[1]=3D<3804>
> argc[2]=3D<UID=3D1000>
> argc[3]=3D<GID=3D1000>
> argc[4]=3D<sig=3D3>
> Total bytes in core dump: 602112
>=20
>=20
>  =C2=A0 /* core_pattern_pipe_test.c */
>=20
>  =C2=A0 =C2=A0 =C2=A0 =C2=A0#define _GNU_SOURCE
>  =C2=A0 =C2=A0 =C2=A0 =C2=A0#include <sys/stat.h>
>  =C2=A0 =C2=A0 =C2=A0 =C2=A0#include <fcntl.h>
>  =C2=A0 =C2=A0 =C2=A0 =C2=A0#include <limits.h>
>  =C2=A0 =C2=A0 =C2=A0 =C2=A0#include <stdio.h>
>  =C2=A0 =C2=A0 =C2=A0 =C2=A0#include <stdlib.h>
>  =C2=A0 =C2=A0 =C2=A0 =C2=A0#include <unistd.h>
>=20
>  =C2=A0 =C2=A0 =C2=A0 =C2=A0#define BUF_SIZE 1024
>=20
>  =C2=A0 =C2=A0 =C2=A0 =C2=A0int
>  =C2=A0 =C2=A0 =C2=A0 =C2=A0main(int argc, char *argv[])
>  =C2=A0 =C2=A0 =C2=A0 =C2=A0{
>  =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0int tot, j;
>  =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0ssize_t nread;
>  =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0char buf[BUF_SIZE];
>  =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0FILE *fp;
>  =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0char cwd[PATH_MAX];
>=20
>  =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0/* Change our current working=
 directory to that of the
>  =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 crashing process */
>=20
>  =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0snprintf(cwd, PATH_MAX, "/pro=
c/%s/cwd", argv[1]);
>  =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0chdir(cwd);
>=20
>  =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0/* Write output to file "core=
=2Einfo" in that directory */
>=20
>  =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0fp =3D fopen("core.info", "w+=
");
>  =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (fp =3D=3D NULL)
>  =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0exit(EXIT_FAILU=
RE);
>=20
>  =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0/* Display command-line argum=
ents given to core_pattern
>  =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 pipe program */
>=20
>  =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0fprintf(fp, "argc=3D%d\n", ar=
gc);
>  =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0for (j =3D 0; j < argc; j++)
>  =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0fprintf(fp, "ar=
gc[%d]=3D<%s>\n", j, argv[j]);
>=20
>  =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0/* Count bytes in standard in=
put (the core dump) */
>=20
>  =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0tot =3D 0;
>  =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0while ((nread =3D read(STDIN_=
FILENO, buf, BUF_SIZE)) > 0)
>  =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0tot +=3D nread;=

>  =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0fprintf(fp, "Total bytes in c=
ore dump: %d\n", tot);
>=20
>  =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0fclose(fp);
>  =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0exit(EXIT_SUCCESS);
>  =C2=A0 =C2=A0 =C2=A0 =C2=A0}
>=20


Are you using system5 or systemd?
0
perl6
9/3/2019 9:49:32 PM
Reply: