Get the process id of the app, which called the service I have an service in automator, which is binded to the Safari ,no input option. 

Now is there any way for the service in automator to get the process id of the Safari, which called it ?

New to applescript and automator. Thanks for the inputs.
As you launch the service from Safari, the application will be the one in the foreground.

You can use this Applescript in the "Run AppleScript" action.

tell application "System Events"
    set x to first process whose its frontmost is true and name is "Safari"
    return unix id of x
end tell