2

It is possible to check if an app bundle's binary process is running in 32 or 64 bit mode, as answered in this question, but I can verify that it only works with GUI processes.

However, I need to also check processes that don't have a GUI and is not part of a bundle.

So, programmatically, without calling system functions or other executables, how can I test if any process is running in 32 or 64 bit mode, given the process pid?

Community
  • 1
  • 1
TheDarkKnight
  • 27,181
  • 6
  • 55
  • 85
  • 1
    Why the C++ and C tags? Isn't your app written in Objective C? – Daniel Hilgarth Oct 02 '13 at 13:32
  • No, it's in C / C++. Objective-C is only required on OSX for GUI applications. Daemons can use C or C++ and kernel extensions are almost always C++ and can not use Objective-C. Just because it's OSX does not mean you are limited to one language. – TheDarkKnight Oct 02 '13 at 13:34
  • The question you linked to is in Objective-C. – Daniel Hilgarth Oct 02 '13 at 13:34
  • @DanielHilgarth Yes, it is, I can mix and match the languages and have found that the Objective-C method does not work for me, so am asking for a C / C++ method. – TheDarkKnight Oct 02 '13 at 13:35
  • @JoachimPileborg, thanks but since the binary could be a universal one containing both 32 and 64 bit code, the source to the File command will not help here. – TheDarkKnight Oct 02 '13 at 13:37
  • possible duplicate of [Is there a way to check if process is 64 bit or 32 bit?](http://stackoverflow.com/questions/7983962/is-there-a-way-to-check-if-process-is-64-bit-or-32-bit) – UpAndAdam Oct 02 '13 at 14:55

1 Answers1

1

Ok, so I finally found the answer was already on SO here, for Carbon. In order to use that code now, this include is required:

#include <sys/sysctl.h>

Also, it appears that the member to the process structure has changed from

proc->kp_proc.p_flags 

to this:

proc->kp_proc.p_flag
Community
  • 1
  • 1
TheDarkKnight
  • 27,181
  • 6
  • 55
  • 85
  • Posted an alternative solution to the question you linked. You can find it here: http://stackoverflow.com/a/27929872/419275 – Dave Jan 13 '15 at 19:26