use strict; use warnings; #-- returns 32 or 64, or 0 in case of error # optional argument: PID of another process; defaults to current PID # see also: http://docs.oracle.com/cd/E26502_01/html/E29030/pflags-1.html (pflags) # http://docs.oracle.com/cd/E26502_01/html/E28556/proc-provider.html (psinfo_t section) # "...The pr_dmodel field is set to either PR_MODEL_ILP32, denoting a 32bit process, # or PR_MODEL_LP64, denoting a 64bit process." # # WARNING! Tested under Solaris 10/11 only! # sub solaris_bits { my $pid = shift || $$; my $pflags = qx{LANG=C /usr/bin/pflags $pid 2>&1}; #-- "data model" should be '_ILP32' or '_LP64' return $pflags =~ /data model\s*=\s*\D*(\d+)/ms ? $1 : 0; } print "Bits (init): ", solaris_bits(1) || 'n/a' , "\n"; # PID==1 (needs privileges!) print "Bits (self): ", solaris_bits() || 'n/a' , "\n"; # PID==$$