Unix Technical Forum

Mistery

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 ...


Go Back   Unix Technical Forum > Unix Operating Systems > Slackware Linux Support

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-20-2008, 06:50 AM
guruteck@gmail.com
 
Posts: n/a
Default Mistery

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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-20-2008, 06:51 AM
guruteck@gmail.com
 
Posts: n/a
Default Re: Mistery


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


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-20-2008, 06:51 AM
Lew Pitcher
 
Posts: n/a
Default Re: Mistery

-----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-----
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-20-2008, 06:51 AM
DB
 
Posts: n/a
Default Re: Mistery

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?"
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 02-20-2008, 06:52 AM
Lew Pitcher
 
Posts: n/a
Default Re: Mistery

-----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-----
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 06:39 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com