different behaviour on fbsd and linux
Petr Rehor
prehor at gmail.com
Sun Feb 19 09:50:02 CET 2006
2006/2/18, Divacky Roman <xdivac02 at stud.fit.vutbr.cz>:
> works differently on fbsd and on linux. on fbsd it basically ls each record in
> ENV on linux it executes ls listing all files in cwd.
Zkusil jsem vymenit ls za echo aby bylo videt jake dostane parametry.
Pro zajimavost tady je vysledek z ruznych systemu na cf.sf.net.
CentOS 4.2, x86
-bash-3.00$ ./a.out
-bash-3.00$
Debian 3.1
reho at x86-linux1:~$ ./a.out
reho at x86-linux1:~$
Fedora FC2
reho at x86-linux2:~$ ./a.out
reho at x86-linux2:~$
Fedora Core 3 on AMD64 Opteron
reho at amd64-linux1:~$ ./a.out
reho at amd64-linux1:~$
Debian 3.0
reho at usf-cf-alpha-linux-1:~$ ./a.out
reho at usf-cf-alpha-linux-1:~$
SuSE Enterprise Server 9 on Power5 - OpenPower 720
reho at openpower-linux1:~> ./a.out
reho at openpower-linux1:~>
Sun Solaris 9 on Sparc - R220
bash-2.05$ ./a.out
bash-2.05$
NetBSD 2.0.2
-bash-2.05b$ ./a.out
-bash-2.05b$ (null): TERM=vt220 SHELL=/bin/bash SSH_CLIENT=10.8.1.2
44958 22 SSH_TTY=/dev/ttyp2 USER=reho
SSH_AUTH_SOCK=/tmp/ssh-026026aa/agent.26026 MAIL=/var/mail/reho
PATH=/usr/bin:/bin:/usr/pkg/bin:/usr/local/bin
PWD=/home/users/r/re/reho SHLVL=1 HOME=/home/users/r/re/reho
LOGNAME=reho SSH_CONNECTION=10.8.1.2 44958 10.8.2.22 22 _=./a.out
OpenBSD 3.8 x86
x86-openbsd1:~$ ./a.out
x86-openbsd1:~$ : TERM=vt220 SHELL=/bin/bash SSH_CLIENT=10.8.1.2 44957
22 SSH_TTY=/dev/ttyp1 USER=reho
SSH_AUTH_SOCK=/tmp/ssh-HpRxv22260/agent.22260 MAIL=/var/mail/reho
PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11R6/bin:/usr/local/bin
PWD=/home/users/r/re/reho SHLVL=1 HOME=/home/users/r/re/reho
LOGNAME=reho SSH_CONNECTION=10.8.1.2 44957 10.8.2.21 22 _=./a.out
Podival jsem se do man execl a tam je napsano, ze prvni parametr je
cesta a druhy je jmeno programu a dalsi jsou paramtery predane
programu a musi koncit NULL. Sice to tam neni explicitne napsane, ale
parametr se jmenem programu je nejspis povinny (chtelo by to kouknout
do POSIXu jak je execl definovany).
Pak se to chova na vsech systemech stejne a spravne:
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
main() {
pid_t pid;
pid = fork();
if (pid == 0)
execl("/bin/ls", "ls", NULL);
}
P.
More information about the Users-l
mailing list