Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the /proc/self/cmdline / GetCommandLine equivalent on Mac OS X?

How can I access the command line on Mac OS X without using argc, argv? On Linux, I would simply read /proc/self/cmdline or use GetCommandLine on Windows, but I can't find the equivalent for Mac OS X.

like image 941
Anteru Avatar asked Nov 03 '22 18:11

Anteru


1 Answers

There are functions called _NSGetArgv and _NSGetArgc in crt_externs.h. However, wouldn't it be simpler to just store the argc/argv in a variable at the start of main and be portable to all three platforms?

NOTE: These functions are not directly documented, but they are mentioned in the documentation for NSApplicationMain in the Application Kit Functions Reference, and the related _NSGetEnviron is mentioned in the environ(7) manpage.

like image 123
Random832 Avatar answered Nov 15 '22 07:11

Random832