Upstart initctl

The upstart package that provides initctl command also provides following other commands:
start , stop , status etc
These commands are all present in /sbin/ in Redhat systems. We can see that status , start , stop , restart are all symlinks to initctl . How do they still work differently? For example to check the status of a job, we can do:

>>> initctl status <job>

We can also do

>>> status <job>

How is that status command works differently when it is a symlink to initctl ?

Thanks
RC

When you exec a program, the name of the file executed (and it doesn't matter if this is a symbolic link or a hard link) typically appears as the "zeroth" argument to the program when it starts running. If the program is a shell script for a shell that is based on Bourne shell syntax, that value can be referenced in the script by the expansion of positional parameter 0 (i.e., $0 ). If you are in a C program where the entry to main is conventionally through the function main with a function prototype similar to:

int main(int argc, char *argv[]);

you could access it in main() by looking at argv[0] .

In either case, if the zeroth argument's last pathname component is initctl , the action to be performed is determined by the 1st argument; otherwise, the last pathname component of the zeroth argument is the action to be performed.

1 Like