This is a discussion on Mistery within the Slackware Linux Support forums, part of the Unix Operating Systems category; --> Hi all I have got a doubt in Softlinks.I normally use program /bin/pidof to know the process id of ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hi all I have got a doubt in Softlinks.I normally use program /bin/pidof to know the process id of a process.But I recently noticed it is a soft link to killall5.But when I use killall5 it kills all processes instead of find the process id. Why this behave like this ??,as both the programs are same . Thanx in advance Regards |
| |||
| gurut...@gmail.com wrote: > Hi all > I have got a doubt in Softlinks.I normally use program /bin/pidof to > know the process id of a process.But I recently noticed it is a soft > link to killall5.But when I use killall5 it kills all processes > instead of find the process id. > Why this behave like this ??,as both the programs are same . > Thanx in advance > Regards |
| |||
| -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 guruteck@gmail.com wrote: > Hi all > I have got a doubt in Softlinks.I normally use program /bin/pidof to > know the process id of a process.But I recently noticed it is a soft > link to killall5.But when I use killall5 it kills all processes > instead of find the process id. > Why this behave like this ??,as both the programs are same . A program can easily check to find out what name it is run under, and change it's behaviour accordingly. int main(int argc, char *argv[]) { if (argc > 0) { if (strcmp(argv[0],"hi") == 0) printf("Hello, world\n"); else if (strcmp(argv[0],"bye") == 0) printf("Goodbye, cruel world\n"); else printf("Whatchu lookn at, Willis?\n"); return 0; } else return 1; } The above will do different things, if it is run as 'hi' or 'bye' or a.out - -- Lew Pitcher IT Specialist, Enterprise Data Systems, Enterprise Technology Solutions, TD Bank Financial Group (Opinions expressed are my own, not my employers') -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (MingW32) iD8DBQFCMZgvagVFX4UWr64RAqaAAJ4xf1fqQubDSsEW3L8bg1 rilr5eEACfa+qH oYjR1/XCPqwnuV491Aio+Gc= =cTGU -----END PGP SIGNATURE----- |
| |||
| Lew Pitcher wrote: > A program can easily check to find out what name it is run under, and change > it's behaviour accordingly. > > int main(int argc, char *argv[]) > { > if (argc > 0) > { > if (strcmp(argv[0],"hi") == 0) > printf("Hello, world\n"); > else if (strcmp(argv[0],"bye") == 0) > printf("Goodbye, cruel world\n"); > else > printf("Whatchu lookn at, Willis?\n"); > return 0; > } > else return 1; > } > > The above will do different things, if it is run as 'hi' or 'bye' or a.out > I think that should be "What u talkin' 'bout, Willis?" |
| ||||
| -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 DB wrote: > Lew Pitcher wrote: > >> A program can easily check to find out what name it is run under, and >> change >> it's behaviour accordingly. #include <stdio.h> #include <stdlib.h> >> int main(int argc, char *argv[]) >> { >> if (argc > 0) >> { >> if (strcmp(argv[0],"hi") == 0) >> printf("Hello, world\n"); >> else if (strcmp(argv[0],"bye") == 0) >> printf("Goodbye, cruel world\n"); >> else >> printf("Whatchu lookn at, Willis?\n"); return EXIT_SUCCESS; >> } else return EXIT_FAILURE; >> } >> >> The above will do different things, if it is run as 'hi' or 'bye' or >> a.out >> > > I think that should be "What u talkin' 'bout, Willis?" Only if you like "Diff'rent Strokes" ;-) - -- Lew Pitcher Master Codewright & JOAT-in-training | GPG public key available on request Registered Linux User #112576 (http://counter.li.org/) Slackware - Because I know what I'm doing. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (GNU/Linux) iD8DBQFCMjmbagVFX4UWr64RAs/SAKCk1zw+FkeQxXN0aZ0IoESc1YUR0gCg2boo /cjn+lyiHtUJeIOUZDuuEbA= =+gXz -----END PGP SIGNATURE----- |
| Thread Tools | |
| Display Modes | |
|
|