Ticket #1817 (closed bug: fixed)

Opened 11 years ago

Last modified 11 years ago

Cannot get the PID on Mac OS X

Reported by: masak Owned by: dukeleto
Priority: normal Milestone:
Component: none Version: 2.8.0
Severity: medium Keywords:
Cc: Language:
Patch status: Platform: darwin


From  http://rt.perl.org/rt3/Ticket/Display.html?id=77850:

<masak> rakudo: say $*PID
<p6eval> rakudo c71489: OUTPUT«12413␤»
<masak> on my box 'say $*PID' prints 0 :/
<masak> can anyone else on Darwin confirm this?
<moritz_> that's a surprisingly low PID?
<masak> too low for my taste...
<florz> actually, that's a non-PID ;-)
<Juerd> masak: Kill it! :)
<masak> 哈哈
<colomon> masak: confirmed
<baest> masak: confirmed
* masak submits rakudobug

From today:

<jnthn> My guess is that there needs to be a Parrot ticket,
since the real issue is probably at that level.
<jnthn> If we're using some Parrot call to get it, but I figure we would be.
<masak> I'll go submit a Trac ticket for the $*PID thing.

Change History

Changed 11 years ago by dukeleto

  • owner set to dukeleto
  • status changed from new to assigned

I will see if I can write a test for this that fails on OS X.

The relevant part of generated PIR code is:

.HLL "perl6"

.namespace []
.sub "_block78"  :anon :subid("65_1286388210.17692") :outer("64_1286388210.17692")
    .param pmc param_87 :optional
    .param int has_param_87 :opt_flag
.annotate 'line', 1
    .local pmc true
    true = get_hll_global 'True'
    .lex "__CANDIDATE_LIST__", $P80
    find_lex_skip_current $P81, "$_"
    $P82 = new ['Perl6Scalar'], $P81
    setprop $P82, "rw", true
    .lex "$_", $P82
    find_lex_skip_current $P83, "$/"
    $P84 = new ['Perl6Scalar'], $P83
    setprop $P84, "rw", true
    .lex "$/", $P84
    find_lex_skip_current $P85, "$!"
    $P86 = new ['Perl6Scalar'], $P85
    setprop $P86, "rw", true
    .lex "$!", $P86
    if has_param_87, optparam_69
    new $P88, "Integer"
    assign $P88, 0
    set param_87, $P88
    .lex "$MAIN", param_87
    $P0 = find_dynamic_lex "$*CTXSAVE"
    if null $P0 goto ctxsave_done
    $I0 = can $P0, "ctxsave"
    unless $I0 goto ctxsave_done
    $P0 = get_hll_global "@!recapture"
    unless $P0 goto recapture_loop_end
    $P1 = shift $P0
    fixup_outer_ctx $P1
    goto recapture_loop
    $P89 = "!find_contextual"("$*PID")
    $P90 = "&say"($P89)
    .return ($P90)


$P89 = "!find_contextual"("$*PID")

is returning 0, either because find_contextual has a bug or $*PID never gets set correctly on darwin.

Changed 11 years ago by moritz

  • status changed from assigned to closed
  • resolution set to fixed

Turns out that Rakudo had some wild code for obtaining the PID of its own, which seemed to be the reason for the 0 on macos x. Now Rakudo has switched to ParrotInterpreter.getpid(), and works like a charm.

Note: See TracTickets for help on using tickets.