PDA

View Full Version : Application Adding Argument




macscriptnew
Jun 7, 2006, 04:53 PM
Hi,

I created a simple application and if i go into the package contents and run the executable it runs fine, but if i click on the icon and try to run it the application is adding an argument to the executable and i get this

paraprof: unknown option '-psn_0_2621441'
Usage: paraprof [--pack <file>] [--dump] [-p] [-m] [-i] [-f <filetype>] <files/directory>

where paraprof is the name of the executable.

does anyone know why it is adding the -psn_0_2621441 when i try to run it from the icon?



HiRez
Jun 7, 2006, 09:10 PM
PSN is the process serial number, which OS X passes as an argument to all applications. It's used for various system things for identifying and discriminating different processes (it will be unique for each time any process is launched). From the Apple dev docs:ProcessSerialNumber
Defines the unique identifier for an open process.

struct ProcessSerialNumber {
unsigned long highLongOfPSN;
unsigned long lowLongOfPSN;
};
typedef struct ProcessSerialNumber ProcessSerialNumber;
typedef ProcessSerialNumber * ProcessSerialNumberPtr;
Fields
highLongOfPSN
The high-order long integer of the process serial number.

lowLongOfPSN
The low-order long integer of the process serial number.

Discussion
All applications (defined as things which can appear in the Dock that are not documents and are launched by the Finder or Dock) on Mac OS X have a unique process serial number. This number is created when the application launches, and remains until the application quits. Other system services, like Apple events, use the ProcessSerialNumber structure to specify an application.

During launch, every application “checks in” with the Process Manager. Before this checkin, the application can not receive events or draw to the screen. Prior to Mac OS 10.2, this check in occurred before the applications's main function was entered. In Mac OS 10.2 and later, this check in does not occur until the first time the application calls a Process Manager function, or until it enters CFRunLoopRun for the main event loop. This allows tools and other executables which do not need to receive events to link against more of the higher level toolbox frameworks, but may cause a problem if the application expects to be able to retrieve events or use CoreGraphics services before this checkin has occurred. An application can force the connection to the Process Manager to be set up by calling any Process Manager routine, but the recommended way to do this is to call GetCurrentProcess to ask for the current application's PSN. Doing so initializes the connection to the Process Manager if it has not already been set up and ”check in“ the application with the system.

You should not make any assumptions about the meaning of the bits in a process serial number. To compare two process serial numbers, you should use the function SameProcess.

You can obtain a process serial number in one of the following ways:

Process serial numbers are returned by the functions LaunchApplication, GetCurrentProcess, and GetFrontProcess.
Some high-level events return process serial numbers.
If you want to specify a process using the “Process Identification Constants”, you must populate a process serial number structure, passing 0 in highLongOfPSN and the appropriate constant (such as kCurrentProcess) in lowLongOfPSN. For example, to bring the current process forward, you can use the following code:

ProcessSerialNumber psn = { 0, kCurrentProcess };
SetFrontProcess( &psn );

savar
Jun 7, 2006, 11:59 PM
PSN is the process serial number, which OS X passes as an argument to all applications. It's used for various system things for identifying and discriminating different processes (it will be unique for each time any process is launched). From the Apple dev docs:

*All applications = all applications which connect to Carbon or Cocoa, from what I can tell. There are a number of unix processes that don't get PSNs.

Edit: ..or maybe its processes which connect to the window server?

fayence
Jun 23, 2006, 06:41 PM
How do I get the path of a file that is dropped onto my icon? All I get is the same -pxn-XXXX stuff, no filename.