4

I see this variable in image_temp_file.rb in makeTempname() in the mini_magick library.

John Feminella
  • 303,634
  • 46
  • 339
  • 357
Tanin
  • 1,853
  • 1
  • 15
  • 20

3 Answers3

5

The $ begins a reference to a global variable. Programs will typically define something like $name and the system predefines a number of information and control references.

$$, in particular, is the process ID.

 
    $name program-defined global variable
    $!  latest error message
    $@  location of error
    $_  string last read by gets
    $.  line number last read by interpreter
    $&  string last matched by regexp
    $~  the last regexp match, as an array of subexpressions
    $n  the nth subexpression in the last match (same as $~[n])
    $=  case-insensitivity flag
    $/  input record separator
    $\  output record separator
    $0  the name of the ruby script file
    $*  the command line arguments
    $$  interpreter's process ID
    $?  exit status of last executed child process
Mattias Wadman
  • 11,172
  • 2
  • 42
  • 57
DigitalRoss
  • 143,651
  • 25
  • 248
  • 329
4

It's the process ID of the Ruby interpreter running the script you're in. For example:

[/tmp] Ψ irb
ruby> $$
 => 16045                          # We're in process id 16045.
ruby> ^Z
[1]+  Stopped irb                  # Let's stop irb so we can
                                   # verify that it's the right pid.

[/tmp] Ψ ps aux | grep -inr 16045  # grep across all processes.
80:johnf    16045  ... irb         # There it is!
John Feminella
  • 303,634
  • 46
  • 339
  • 357
0

$$ evaluates to the process id of the running program.

phlogratos
  • 13,234
  • 1
  • 32
  • 37