前两天想用perl写个daemon进程来做些事情,但是后来发现日志一直没有办法打出来。先看类似的脚本
- #!/usr/bin/perl
-
use strict;
-
use warnings;
-
open LOG,">test.out" or die "open file failed\n";
-
foreach my $k (0..25)
-
{
-
-
print LOG ($k,"\n");
-
sleep(1);
-
}
在运行这个脚本后,我们可以另外开个窗口,然后你会发现tail -f test.out的时候一直没有任何输出,直到最后程序结束的时候才会一下子都显示出来的。
strace一下我们可以发现
- $ strace ./c.pl |tee ss.log
-
execve("./c.pl", ["./c.pl"], [/* 27 vars */]) = 0
-
brk(0) = 0x63b0000
-
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2b6176354000
-
uname({sys="Linux", node="free71-170-stable.alipay.net", ...}) = 0
-
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
-
open("/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/CORE/tls/x86_64/libperl.so", O_RDONLY) = -1 ENOENT (No such file or directory)
-
stat("/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/CORE/tls/x86_64", 0x7fff41a3c490) = -1 ENOENT (No such file or directory)
-
open("/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/CORE/tls/libperl.so", O_RDONLY) = -1 ENOENT (No such file or directory)
-
stat("/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/CORE/tls", 0x7fff41a3c490) = -1 ENOENT (No such file or directory)
-
open("/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/CORE/x86_64/libperl.so", O_RDONLY) = -1 ENOENT (No such file or directory)
-
stat("/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/CORE/x86_64", 0x7fff41a3c490) = -1 ENOENT (No such file or directory)
-
open("/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/CORE/libperl.so", O_RDONLY) = 3
-
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\340\34\3\3004\0\0\0"..., 832) = 832
-
fstat(3, {st_mode=S_IFREG|0755, st_size=1262288, ...}) = 0
-
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2b6176355000
-
mmap(0x34c0000000, 3363552, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x34c0000000
-
mprotect(0x34c012b000, 2097152, PROT_NONE) = 0
-
mmap(0x34c032b000, 36864, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x12b000) = 0x34c032b000
-
mmap(0x34c0334000, 4832, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x34c0334000
-
close(3) = 0
-
open("/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/CORE/libresolv.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
-
open("/etc/ld.so.cache", O_RDONLY) = 3
-
fstat(3, {st_mode=S_IFREG|0644, st_size=81032, ...}) = 0
-
mmap(NULL, 81032, PROT_READ, MAP_PRIVATE, 3, 0) = 0x2b6176356000
-
close(3) = 0
-
open("/lib64/libresolv.so.2", O_RDONLY) = 3
-
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\2402@\3054\0\0\0"..., 832) = 832
-
fstat(3, {st_mode=S_IFREG|0755, st_size=92736, ...}) = 0
-
mmap(0x34c5400000, 2181864, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x34c5400000
-
mprotect(0x34c5411000, 2097152, PROT_NONE) = 0
-
mmap(0x34c5611000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x11000) = 0x34c5611000
-
mmap(0x34c5613000, 6888, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x34c5613000
-
close(3) = 0
-
open("/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/CORE/libnsl.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
-
open("/lib64/libnsl.so.1", O_RDONLY) = 3
-
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\240@\0\3024\0\0\0"..., 832) = 832
-
fstat(3, {st_mode=S_IFREG|0755, st_size=114352, ...}) = 0
-
mmap(0x34c2000000, 2194096, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x34c2000000
-
mprotect(0x34c2015000, 2093056, PROT_NONE) = 0
-
mmap(0x34c2214000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x14000) = 0x34c2214000
-
mmap(0x34c2216000, 6832, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x34c2216000
-
close(3) = 0
-
open("/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/CORE/libdl.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
-
open("/lib64/libdl.so.2", O_RDONLY) = 3
-
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\20\16\0\2764\0\0\0"..., 832) = 832
-
fstat(3, {st_mode=S_IFREG|0755, st_size=23360, ...}) = 0
-
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2b617636a000
-
mmap(0x34be000000, 2109696, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x34be000000
-
mprotect(0x34be002000, 2097152, PROT_NONE) = 0
-
mmap(0x34be202000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x2000) = 0x34be202000
-
close(3) = 0
-
open("/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/CORE/libm.so.6", O_RDONLY) = -1 ENOENT (No such file or directory)
-
open("/lib64/libm.so.6", O_RDONLY) = 3
-
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0`>@\2764\0\0\0"..., 832) = 832
-
fstat(3, {st_mode=S_IFREG|0755, st_size=615136, ...}) = 0
-
mmap(0x34be400000, 2629848, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x34be400000
-
mprotect(0x34be482000, 2093056, PROT_NONE) = 0
-
mmap(0x34be681000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x81000) = 0x34be681000
-
close(3) = 0
-
open("/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/CORE/libcrypt.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
-
open("/lib64/libcrypt.so.1", O_RDONLY) = 3
-
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\360\t\300\2774\0\0\0"..., 832) = 832
-
fstat(3, {st_mode=S_IFREG|0755, st_size=48600, ...}) = 0
-
mmap(0x34bfc00000, 2322880, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x34bfc00000
-
mprotect(0x34bfc09000, 2093056, PROT_NONE) = 0
-
mmap(0x34bfe08000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x8000) = 0x34bfe08000
-
mmap(0x34bfe0a000, 184768, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x34bfe0a000
-
close(3) = 0
-
open("/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/CORE/libutil.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
-
open("/lib64/libutil.so.1", O_RDONLY) = 3
-
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\200\16\340\3154\0\0\0"..., 832) = 832
-
fstat(3, {st_mode=S_IFREG|0755, st_size=18152, ...}) = 0
-
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2b617636b000
-
mmap(0x34cde00000, 2105616, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x34cde00000
-
mprotect(0x34cde02000, 2093056, PROT_NONE) = 0
-
mmap(0x34ce001000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1000) = 0x34ce001000
-
close(3) = 0
-
open("/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/CORE/libpthread.so.0", O_RDONLY) = -1 ENOENT (No such file or directory)
-
open("/lib64/libpthread.so.0", O_RDONLY) = 3
-
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\240W\200\2764\0\0\0"..., 832) = 832
-
fstat(3, {st_mode=S_IFREG|0755, st_size=145824, ...}) = 0
-
mmap(0x34be800000, 2204528, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x34be800000
-
mprotect(0x34be816000, 2093056, PROT_NONE) = 0
-
mmap(0x34bea15000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x15000) = 0x34bea15000
-
mmap(0x34bea17000, 13168, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x34bea17000
-
close(3) = 0
-
open("/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/CORE/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory)
-
open("/lib64/libc.so.6", O_RDONLY) = 3
-
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\220\332\301\2754\0\0\0"..., 832) = 832
-
fstat(3, {st_mode=S_IFREG|0755, st_size=1717800, ...}) = 0
-
mmap(0x34bdc00000, 3498328, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x34bdc00000
-
mprotect(0x34bdd4e000, 2093056, PROT_NONE) = 0
-
mmap(0x34bdf4d000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x14d000) = 0x34bdf4d000
-
mmap(0x34bdf52000, 16728, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x34bdf52000
-
close(3) = 0
-
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2b617636c000
-
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2b617636d000
-
arch_prctl(ARCH_SET_FS, 0x2b617636d250) = 0
-
mprotect(0x34c5611000, 4096, PROT_READ) = 0
-
mprotect(0x34c2214000, 4096, PROT_READ) = 0
-
mprotect(0x34be202000, 4096, PROT_READ) = 0
-
mprotect(0x34be681000, 4096, PROT_READ) = 0
-
mprotect(0x34bfe08000, 4096, PROT_READ) = 0
-
mprotect(0x34ce001000, 4096, PROT_READ) = 0
-
mprotect(0x34bea15000, 4096, PROT_READ) = 0
-
mprotect(0x34bdf4d000, 16384, PROT_READ) = 0
-
mprotect(0x34bda1b000, 4096, PROT_READ) = 0
-
munmap(0x2b6176356000, 81032) = 0
-
set_tid_address(0x2b617636d2e0) = 3872
-
set_robust_list(0x2b617636d2f0, 0x18) = 0
-
futex(0x7fff41a3cfbc, FUTEX_WAKE_PRIVATE, 1) = 0
-
rt_sigaction(SIGRTMIN, {0x34be805380, [], SA_RESTORER|SA_SIGINFO, 0x34be80eb10}, NULL, 8) = 0
-
rt_sigaction(SIGRT_1, {0x34be8052b0, [], SA_RESTORER|SA_RESTART|SA_SIGINFO, 0x34be80eb10}, NULL, 8) = 0
-
rt_sigprocmask(SIG_UNBLOCK, [RTMIN RT_1], NULL, 8) = 0
-
getrlimit(RLIMIT_STACK, {rlim_cur=10240*1024, rlim_max=RLIM_INFINITY}) = 0
-
rt_sigaction(SIGFPE, {0x1, [FPE], SA_RESTORER|SA_RESTART, 0x34bdc302d0}, {SIG_DFL, [], 0}, 8) = 0
-
brk(0) = 0x63b0000
-
brk(0x63d2000) = 0x63d2000
-
getuid() = 1801
-
geteuid() = 1801
-
getgid() = 1000
-
getegid() = 1000
-
open("/usr/lib/locale/locale-archive", O_RDONLY) = 3
-
fstat(3, {st_mode=S_IFREG|0644, st_size=56466992, ...}) = 0
-
mmap(NULL, 56466992, PROT_READ, MAP_PRIVATE, 3, 0) = 0x2b617636e000
-
close(3) = 0
-
mmap(NULL, 135168, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2b6179948000
-
open("/dev/urandom", O_RDONLY) = 3
-
read(3, "Q\3\7w", 4) = 4
-
close(3) = 0
-
time([1330767532]) = 1330767532
-
stat("/usr/lib64/perl5/site_perl/5.8.7/x86_64-linux-thread-multi", 0x7fff41a3cc70) = -1 ENOENT (No such file or directory)
-
stat("/usr/lib/perl5/site_perl/5.8.7", 0x7fff41a3cc70) = -1 ENOENT (No such file or directory)
-
stat("/usr/lib64/perl5/site_perl/5.8.6/x86_64-linux-thread-multi", 0x7fff41a3cc70) = -1 ENOENT (No such file or directory)
-
stat("/usr/lib/perl5/site_perl/5.8.6", 0x7fff41a3cc70) = -1 ENOENT (No such file or directory)
-
stat("/usr/lib64/perl5/site_perl/5.8.5/x86_64-linux-thread-multi", 0x7fff41a3cc70) = -1 ENOENT (No such file or directory)
-
stat("/usr/lib/perl5/site_perl/5.8.5", 0x7fff41a3cc70) = -1 ENOENT (No such file or directory)
-
stat("/usr/lib64/perl5/vendor_perl/5.8.7/x86_64-linux-thread-multi", 0x7fff41a3cc70) = -1 ENOENT (No such file or directory)
-
stat("/usr/lib/perl5/vendor_perl/5.8.7", 0x7fff41a3cc70) = -1 ENOENT (No such file or directory)
-
stat("/usr/lib64/perl5/vendor_perl/5.8.6/x86_64-linux-thread-multi", 0x7fff41a3cc70) = -1 ENOENT (No such file or directory)
-
stat("/usr/lib/perl5/vendor_perl/5.8.6", 0x7fff41a3cc70) = -1 ENOENT (No such file or directory)
-
stat("/usr/lib64/perl5/vendor_perl/5.8.5/x86_64-linux-thread-multi", 0x7fff41a3cc70) = -1 ENOENT (No such file or directory)
-
stat("/usr/lib/perl5/vendor_perl/5.8.5", 0x7fff41a3cc70) = -1 ENOENT (No such file or directory)
-
ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 0
-
lseek(0, 0, SEEK_CUR) = -1 ESPIPE (Illegal seek)
-
ioctl(1, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fff41a3ca30) = -1 EINVAL (Invalid argument)
-
lseek(1, 0, SEEK_CUR) = -1 ESPIPE (Illegal seek)
-
ioctl(2, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 0
-
lseek(2, 0, SEEK_CUR) = -1 ESPIPE (Illegal seek)
-
open("./c.pl", O_RDONLY) = 3
-
ioctl(3, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fff41a3cb40) = -1 ENOTTY (Inappropriate ioctl for device)
-
lseek(3, 0, SEEK_CUR) = 0
-
fcntl(3, F_SETFD, FD_CLOEXEC) = 0
-
fstat(3, {st_mode=S_IFREG|0755, st_size=191, ...}) = 0
-
rt_sigaction(SIGCHLD, NULL, {SIG_DFL, [], 0}, 8) = 0
-
readlink("/proc/self/exe", "/usr/bin/perl"..., 4095) = 13
-
brk(0x63f3000) = 0x63f3000
-
read(3, "#!/usr/bin/perl\nuse strict;\nuse "..., 4096) = 191
-
stat("/usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/strict.pmc", 0x7fff41a3c770) = -1 ENOENT (No such file or directory)
-
stat("/usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/strict.pm", 0x7fff41a3c630) = -1 ENOENT (No such file or directory)
-
stat("/usr/lib/perl5/site_perl/5.8.8/strict.pmc", 0x7fff41a3c770) = -1 ENOENT (No such file or directory)
-
stat("/usr/lib/perl5/site_perl/5.8.8/strict.pm", 0x7fff41a3c630) = -1 ENOENT (No such file or directory)
-
stat("/usr/lib/perl5/site_perl/strict.pmc", 0x7fff41a3c770) = -1 ENOENT (No such file or directory)
-
stat("/usr/lib/perl5/site_perl/strict.pm", 0x7fff41a3c630) = -1 ENOENT (No such file or directory)
-
stat("/usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi/strict.pmc", 0x7fff41a3c770) = -1 ENOENT (No such file or directory)
-
stat("/usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi/strict.pm", 0x7fff41a3c630) = -1 ENOENT (No such file or directory)
-
stat("/usr/lib/perl5/vendor_perl/5.8.8/strict.pmc", 0x7fff41a3c770) = -1 ENOENT (No such file or directory)
-
stat("/usr/lib/perl5/vendor_perl/5.8.8/strict.pm", 0x7fff41a3c630) = -1 ENOENT (No such file or directory)
-
stat("/usr/lib/perl5/vendor_perl/strict.pmc", 0x7fff41a3c770) = -1 ENOENT (No such file or directory)
-
stat("/usr/lib/perl5/vendor_perl/strict.pm", 0x7fff41a3c630) = -1 ENOENT (No such file or directory)
-
stat("/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/strict.pmc", 0x7fff41a3c770) = -1 ENOENT (No such file or directory)
-
stat("/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/strict.pm", 0x7fff41a3c630) = -1 ENOENT (No such file or directory)
-
stat("/usr/lib/perl5/5.8.8/strict.pmc", 0x7fff41a3c770) = -1 ENOENT (No such file or directory)
-
stat("/usr/lib/perl5/5.8.8/strict.pm", {st_mode=S_IFREG|0644, st_size=3292, ...}) = 0
-
open("/usr/lib/perl5/5.8.8/strict.pm", O_RDONLY) = 4
-
ioctl(4, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fff41a3c3c0) = -1 ENOTTY (Inappropriate ioctl for device)
-
lseek(4, 0, SEEK_CUR) = 0
-
read(4, "package strict;\n\n$strict::VERSIO"..., 4096) = 3292
-
lseek(4, 598, SEEK_SET) = 598
-
lseek(4, 0, SEEK_CUR) = 598
-
close(4) = 0
-
stat("/usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/warnings.pmc", 0x7fff41a3c770) = -1 ENOENT (No such file or directory)
-
stat("/usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/warnings.pm", 0x7fff41a3c630) = -1 ENOENT (No such file or directory)
-
stat("/usr/lib/perl5/site_perl/5.8.8/warnings.pmc", 0x7fff41a3c770) = -1 ENOENT (No such file or directory)
-
stat("/usr/lib/perl5/site_perl/5.8.8/warnings.pm", 0x7fff41a3c630) = -1 ENOENT (No such file or directory)
-
stat("/usr/lib/perl5/site_perl/warnings.pmc", 0x7fff41a3c770) = -1 ENOENT (No such file or directory)
-
stat("/usr/lib/perl5/site_perl/warnings.pm", 0x7fff41a3c630) = -1 ENOENT (No such file or directory)
-
stat("/usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi/warnings.pmc", 0x7fff41a3c770) = -1 ENOENT (No such file or directory)
-
stat("/usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi/warnings.pm", 0x7fff41a3c630) = -1 ENOENT (No such file or directory)
-
stat("/usr/lib/perl5/vendor_perl/5.8.8/warnings.pmc", 0x7fff41a3c770) = -1 ENOENT (No such file or directory)
-
stat("/usr/lib/perl5/vendor_perl/5.8.8/warnings.pm", 0x7fff41a3c630) = -1 ENOENT (No such file or directory)
-
stat("/usr/lib/perl5/vendor_perl/warnings.pmc", 0x7fff41a3c770) = -1 ENOENT (No such file or directory)
-
stat("/usr/lib/perl5/vendor_perl/warnings.pm", 0x7fff41a3c630) = -1 ENOENT (No such file or directory)
-
stat("/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/warnings.pmc", 0x7fff41a3c770) = -1 ENOENT (No such file or directory)
-
stat("/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/warnings.pm", 0x7fff41a3c630) = -1 ENOENT (No such file or directory)
-
stat("/usr/lib/perl5/5.8.8/warnings.pmc", 0x7fff41a3c770) = -1 ENOENT (No such file or directory)
-
stat("/usr/lib/perl5/5.8.8/warnings.pm", {st_mode=S_IFREG|0644, st_size=15879, ...}) = 0
-
open("/usr/lib/perl5/5.8.8/warnings.pm", O_RDONLY) = 4
-
ioctl(4, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fff41a3c3c0) = -1 ENOTTY (Inappropriate ioctl for device)
-
lseek(4, 0, SEEK_CUR) = 0
-
read(4, "# -*- buffer-read-only: t -*-\n# "..., 4096) = 4096
-
stat("/usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/Carp.pmc", 0x7fff41a3c1b0) = -1 ENOENT (No such file or directory)
-
stat("/usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/Carp.pm", 0x7fff41a3c070) = -1 ENOENT (No such file or directory)
-
stat("/usr/lib/perl5/site_perl/5.8.8/Carp.pmc", 0x7fff41a3c1b0) = -1 ENOENT (No such file or directory)
-
stat("/usr/lib/perl5/site_perl/5.8.8/Carp.pm", 0x7fff41a3c070) = -1 ENOENT (No such file or directory)
-
stat("/usr/lib/perl5/site_perl/Carp.pmc", 0x7fff41a3c1b0) = -1 ENOENT (No such file or directory)
-
stat("/usr/lib/perl5/site_perl/Carp.pm", 0x7fff41a3c070) = -1 ENOENT (No such file or directory)
-
stat("/usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi/Carp.pmc", 0x7fff41a3c1b0) = -1 ENOENT (No such file or directory)
-
stat("/usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi/Carp.pm", 0x7fff41a3c070) = -1 ENOENT (No such file or directory)
-
stat("/usr/lib/perl5/vendor_perl/5.8.8/Carp.pmc", 0x7fff41a3c1b0) = -1 ENOENT (No such file or directory)
-
stat("/usr/lib/perl5/vendor_perl/5.8.8/Carp.pm", 0x7fff41a3c070) = -1 ENOENT (No such file or directory)
-
stat("/usr/lib/perl5/vendor_perl/Carp.pmc", 0x7fff41a3c1b0) = -1 ENOENT (No such file or directory)
-
stat("/usr/lib/perl5/vendor_perl/Carp.pm", 0x7fff41a3c070) = -1 ENOENT (No such file or directory)
-
stat("/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/Carp.pmc", 0x7fff41a3c1b0) = -1 ENOENT (No such file or directory)
-
stat("/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/Carp.pm", 0x7fff41a3c070) = -1 ENOENT (No such file or directory)
-
stat("/usr/lib/perl5/5.8.8/Carp.pmc", 0x7fff41a3c1b0) = -1 ENOENT (No such file or directory)
-
stat("/usr/lib/perl5/5.8.8/Carp.pm", {st_mode=S_IFREG|0644, st_size=8840, ...}) = 0
-
open("/usr/lib/perl5/5.8.8/Carp.pm", O_RDONLY) = 5
-
ioctl(5, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fff41a3be00) = -1 ENOTTY (Inappropriate ioctl for device)
-
lseek(5, 0, SEEK_CUR) = 0
-
read(5, "package Carp;\n\nour $VERSION = '1"..., 4096) = 4096
-
read(5, "an not get %CarpInternal or %Int"..., 4096) = 4096
-
read(5, "need to (for Safe compartments)\n"..., 4096) = 648
-
read(5, "", 4096) = 0
-
close(5) = 0
-
stat("/usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/Exporter.pmc", 0x7fff41a3c1b0) = -1 ENOENT (No such file or directory)
-
stat("/usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/Exporter.pm", 0x7fff41a3c070) = -1 ENOENT (No such file or directory)
-
stat("/usr/lib/perl5/site_perl/5.8.8/Exporter.pmc", 0x7fff41a3c1b0) = -1 ENOENT (No such file or directory)
-
stat("/usr/lib/perl5/site_perl/5.8.8/Exporter.pm", 0x7fff41a3c070) = -1 ENOENT (No such file or directory)
-
stat("/usr/lib/perl5/site_perl/Exporter.pmc", 0x7fff41a3c1b0) = -1 ENOENT (No such file or directory)
-
stat("/usr/lib/perl5/site_perl/Exporter.pm", 0x7fff41a3c070) = -1 ENOENT (No such file or directory)
-
stat("/usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi/Exporter.pmc", 0x7fff41a3c1b0) = -1 ENOENT (No such file or directory)
-
stat("/usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi/Exporter.pm", 0x7fff41a3c070) = -1 ENOENT (No such file or directory)
-
stat("/usr/lib/perl5/vendor_perl/5.8.8/Exporter.pmc", 0x7fff41a3c1b0) = -1 ENOENT (No such file or directory)
-
stat("/usr/lib/perl5/vendor_perl/5.8.8/Exporter.pm", 0x7fff41a3c070) = -1 ENOENT (No such file or directory)
-
stat("/usr/lib/perl5/vendor_perl/Exporter.pmc", 0x7fff41a3c1b0) = -1 ENOENT (No such file or directory)
-
stat("/usr/lib/perl5/vendor_perl/Exporter.pm", 0x7fff41a3c070) = -1 ENOENT (No such file or directory)
-
stat("/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/Exporter.pmc", 0x7fff41a3c1b0) = -1 ENOENT (No such file or directory)
-
stat("/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/Exporter.pm", 0x7fff41a3c070) = -1 ENOENT (No such file or directory)
-
stat("/usr/lib/perl5/5.8.8/Exporter.pmc", 0x7fff41a3c1b0) = -1 ENOENT (No such file or directory)
-
stat("/usr/lib/perl5/5.8.8/Exporter.pm", {st_mode=S_IFREG|0644, st_size=14419, ...}) = 0
-
open("/usr/lib/perl5/5.8.8/Exporter.pm", O_RDONLY) = 5
-
ioctl(5, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fff41a3be00) = -1 ENOTTY (Inappropriate ioctl for device)
-
lseek(5, 0, SEEK_CUR) = 0
-
read(5, "package Exporter;\n\nrequire 5.006"..., 4096) = 4096
-
brk(0x6414000) = 0x6414000
-
lseek(5, 2217, SEEK_SET) = 2217
-
lseek(5, 0, SEEK_CUR) = 2217
-
close(5) = 0
-
read(4, ",\n 'void'\t\t=> 90,\n 'y2k'\t\t"..., 4096) = 4096
-
read(4, "x00\\x00\\x20\\x00\\x00\\x00\\x00\\x00\\"..., 4096) = 4096
-
read(4, " $mask = ${^WARNING_BITS} ;\n\n "..., 4096) = 3591
-
brk(0x6435000) = 0x6435000
-
read(4, "", 4096) = 0
-
close(4) = 0
-
read(3, "", 4096) = 0
-
close(3) = 0
-
open("test.out", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3
-
ioctl(3, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fff41a3ca10) = -1 ENOTTY (Inappropriate ioctl for device)
-
lseek(3, 0, SEEK_CUR) = 0
-
fstat(3, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
-
fcntl(3, F_SETFD, FD_CLOEXEC) = 0
-
time([1330767532]) = 1330767532
-
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
-
rt_sigaction(SIGCHLD, NULL, {SIG_DFL, [], 0}, 8) = 0
-
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
-
nanosleep({1, 0}, {1, 0}) = 0
-
time([1330767533]) = 1330767533
-
time([1330767533]) = 1330767533
-
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
-
rt_sigaction(SIGCHLD, NULL, {SIG_DFL, [], 0}, 8) = 0
-
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
-
nanosleep({1, 0}, {1, 0}) = 0
-
time([1330767534]) = 1330767534
-
time([1330767534]) = 1330767534
-
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
-
rt_sigaction(SIGCHLD, NULL, {SIG_DFL, [], 0}, 8) = 0
-
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
-
nanosleep({1, 0}, {1, 0}) = 0
-
time([1330767536]) = 1330767536
-
time([1330767536]) = 1330767536
-
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
-
rt_sigaction(SIGCHLD, NULL, {SIG_DFL, [], 0}, 8) = 0
-
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
-
nanosleep({1, 0}, {1, 0}) = 0
-
time([1330767537]) = 1330767537
-
time([1330767537]) = 1330767537
-
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
-
rt_sigaction(SIGCHLD, NULL, {SIG_DFL, [], 0}, 8) = 0
-
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
-
nanosleep({1, 0}, {1, 0}) = 0
-
time([1330767538]) = 1330767538
-
time([1330767538]) = 1330767538
-
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
-
rt_sigaction(SIGCHLD, NULL, {SIG_DFL, [], 0}, 8) = 0
-
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
-
nanosleep({1, 0}, {1, 0}) = 0
-
time([1330767539]) = 1330767539
-
write(3, "0\n1\n2\n3\n4\n5\n", 12) = 12
-
close(3) = 0
-
exit_group(0) = ?
从上面我标成红色的sleep前的操作来看,每次sleep前其实没有打印任何内容到描述符3。而且最后才一次性打印到3的。
我们对前面的脚本稍微做修改后
- #!/usr/bin/perl
-
use strict;
-
use warnings;
-
use IO::Handle;
-
open LOG,">test.out" or die "open file failed\n";
-
LOG->autoflush();
-
foreach my $k (0..25)
-
{
-
-
print LOG ($k,"\n");
-
sleep(1);
-
}
这次会发现每次都割1秒会直接输出了吧。具体的原因google "autoflush + perl"就知道了。
其实也可以直接使用syswrite来做
- #!/usr/bin/perl
-
use strict;
-
use warnings;
-
open LOG,">test.out" or die "open file failed\n";
-
foreach my $k (0..25)
-
{
-
syswrite(LOG,"$k\n",1024);
-
sleep(1);
-
}
阅读(2501) | 评论(0) | 转发(0) |