bash – 为什么Perl的打印不能输出任何东西到STDOUT和STDERR,但是写入文件成功?

前端之家收集整理的这篇文章主要介绍了bash – 为什么Perl的打印不能输出任何东西到STDOUT和STDERR,但是写入文件成功?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我试图从以下Perl脚本打印到标准版本,但它不会在屏幕上产生任何输出.然而,它会打印到文件.
  1. #!/usr/bin/perl
  2. use warnings;
  3. use strict;
  4.  
  5. print "Here's some text\n";
  6. print STDERR "Here's some text\n";
  7. print STDOUT "Here's some text\n";
  8.  
  9. open FH,">","file.txt" or die $!;
  10.  
  11. print FH "Here's some text\n";

我试着检查我使用的perl版本(perl -v),但是也没有输出任何东西. perl手册页面告诉我我正在使用5.14.2.我从Raspberry Pi的bash提示符中运行Perl脚本.

我看到这个类似的帖子Print: producing no output,所以我用strace,看到输出没有包括任何写命令.

  1. strace perl -we'print("a") or die("Can'\''t print: $!\n");'

以下是完整脚本的strace输出

  1. execve("./response",["./response"],[/* 18 vars */]) = 0
  2. brk(0) = 0xd98000
  3. uname({sys="Linux",node="raspberrypi",...}) = 0
  4. access("/etc/ld.so.nohwcap",F_OK) = -1 ENOENT (No such file or directory)
  5. mmap2(NULL,8192,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANONYMOUS,-1,0) = 0xb6f99000
  6. access("/etc/ld.so.preload",R_OK) = 0
  7. open("/etc/ld.so.preload",O_RDONLY) = 3
  8. fstat64(3,{st_mode=S_IFREG|0644,st_size=44,...}) = 0
  9. mmap2(NULL,44,MAP_PRIVATE,3,0) = 0xb6f98000
  10. close(3) = 0
  11. open("/usr/lib/arm-linux-gnueabihf/libcofi_rpi.so",O_RDONLY) = 3
  12. read(3,"\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\270\4\0\0004\0\0\0"...,512) = 512
  13. lseek(3,7276,SEEK_SET) = 7276
  14. read(3,"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"...,1080) = 1080
  15. lseek(3,7001,SEEK_SET) = 7001
  16. read(3,"A.\0\0\0aeabi\0\1$\0\0\0\0056\0\6\6\10\1\t\1\n\2\22\4\24\1\25"...,47) = 47
  17. fstat64(3,{st_mode=S_IFREG|0755,st_size=10170,39740,PROT_READ|PROT_EXEC,MAP_PRIVATE|MAP_DENYWRITE,0) = 0xb6f6c000
  18. mprotect(0xb6f6e000,28672,PROT_NONE) = 0
  19. mmap2(0xb6f75000,4096,MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE,0x1) = 0xb6f75000
  20. close(3) = 0
  21. munmap(0xb6f98000,44) = 0
  22. open("/etc/ld.so.cache",O_RDONLY) = 3
  23. fstat64(3,st_size=64456,64456,PROT_READ,0) = 0xb6f5c000
  24. close(3) = 0
  25. access("/etc/ld.so.nohwcap",F_OK) = -1 ENOENT (No such file or directory)
  26. open("/usr/lib/libperl.so.5.14","\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\220\v\2\0004\0\0\0"...,1346508,SEEK_SET) = 1346508
  27. read(3,1120) = 1120
  28. lseek(3,1346184,SEEK_SET) = 1346184
  29. read(3,"A2\0\0\0aeabi\0\1(\0\0\0\0056\0\6\6\10\1\t\1\n\2\22\4\24\1\25"...,51) = 51
  30. fstat64(3,st_size=1347628,1379192,0) = 0xb6e0b000
  31. mprotect(0xb6f4f000,32768,PROT_NONE) = 0
  32. mmap2(0xb6f57000,20480,0x144) = 0xb6f57000
  33. close(3) = 0
  34. access("/etc/ld.so.nohwcap",F_OK) = -1 ENOENT (No such file or directory)
  35. open("/lib/arm-linux-gnueabihf/libdl.so.2","\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0(\t\0\0004\0\0\0"...,8652,SEEK_SET) = 8652
  36. read(3,1160) = 1160
  37. lseek(3,8320,SEEK_SET) = 8320
  38. read(3,"A0\0\0\0aeabi\0\1&\0\0\0\0056\0\6\6\10\1\t\1\n\2\22\4\24\1\25"...,49) = 49
  39. fstat64(3,st_size=9812,41136,0) = 0xb6e00000
  40. mprotect(0xb6e02000,PROT_NONE) = 0
  41. mmap2(0xb6e09000,0x1) = 0xb6e09000
  42. close(3) = 0
  43. access("/etc/ld.so.nohwcap",F_OK) = -1 ENOENT (No such file or directory)
  44. open("/lib/arm-linux-gnueabihf/libm.so.6","\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\3201\0\0004\0\0\0"...,426468,SEEK_SET) = 426468
  45. read(3,426136,SEEK_SET) = 426136
  46. read(3,st_size=427628,458912,0) = 0xb6d8f000
  47. mprotect(0xb6df7000,PROT_NONE) = 0
  48. mmap2(0xb6dfe000,0x67) = 0xb6dfe000
  49. close(3) = 0
  50. access("/etc/ld.so.nohwcap",F_OK) = -1 ENOENT (No such file or directory)
  51. open("/lib/arm-linux-gnueabihf/libpthread.so.0","\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\274V\0\0004\0\0\0"...,82712,SEEK_SET) = 82712
  52. read(3,1400) = 1400
  53. lseek(3,82308,SEEK_SET) = 82308
  54. read(3,st_size=116462,123412,0) = 0xb6d70000
  55. mprotect(0xb6d84000,PROT_NONE) = 0
  56. mmap2(0xb6d8b000,0x13) = 0xb6d8b000
  57. mmap2(0xb6d8d000,4628,MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS,0) = 0xb6d8d000
  58. close(3) = 0
  59. access("/etc/ld.so.nohwcap",F_OK) = -1 ENOENT (No such file or directory)
  60. open("/lib/arm-linux-gnueabihf/libc.so.6","\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\214y\1\0004\0\0\0"...,1215264,SEEK_SET) = 1215264
  61. read(3,1360) = 1360
  62. lseek(3,1214828,SEEK_SET) = 1214828
  63. read(3,st_size=1216624,0) = 0xb6f98000
  64. mmap2(NULL,1258784,0) = 0xb6c3c000
  65. mprotect(0xb6d62000,PROT_NONE) = 0
  66. mmap2(0xb6d6a000,12288,0x126) = 0xb6d6a000
  67. mmap2(0xb6d6d000,9504,0) = 0xb6d6d000
  68. close(3) = 0
  69. access("/etc/ld.so.nohwcap",F_OK) = -1 ENOENT (No such file or directory)
  70. open("/lib/arm-linux-gnueabihf/libcrypt.so.1","\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\30\7\0\0004\0\0\0"...,29116,SEEK_SET) = 29116
  71. read(3,28780,SEEK_SET) = 28780
  72. read(3,st_size=30276,221504,0) = 0xb6c05000
  73. mprotect(0xb6c0c000,PROT_NONE) = 0
  74. mmap2(0xb6c13000,0x6) = 0xb6c13000
  75. mmap2(0xb6c15000,155968,0) = 0xb6c15000
  76. close(3) = 0
  77. access("/etc/ld.so.nohwcap",F_OK) = -1 ENOENT (No such file or directory)
  78. open("/lib/arm-linux-gnueabihf/libgcc_s.so.1","\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0`\364\0\0004\0\0\0"...,130212,SEEK_SET) = 130212
  79. read(3,129880,SEEK_SET) = 129880
  80. read(3,st_size=131372,162704,0) = 0xb6bdd000
  81. mprotect(0xb6bfd000,PROT_NONE) = 0
  82. mmap2(0xb6c04000,0x1f) = 0xb6c04000
  83. close(3) = 0
  84. mmap2(NULL,0) = 0xb6f97000
  85. set_tls(0xb6f976d0,0xb6f97da8,0xb6f9c048,0xb6f976d0,0xb6f9c048) = 0
  86. mprotect(0xb6c13000,PROT_READ) = 0
  87. mprotect(0xb6d6a000,PROT_READ) = 0
  88. mprotect(0xb6d8b000,PROT_READ) = 0
  89. mprotect(0xb6dfe000,PROT_READ) = 0
  90. mprotect(0xb6e09000,PROT_READ) = 0
  91. mprotect(0xb6f57000,PROT_READ) = 0
  92. mprotect(0x11000,PROT_READ) = 0
  93. mprotect(0xb6f9b000,PROT_READ) = 0
  94. munmap(0xb6f5c000,64456) = 0
  95. set_tid_address(0xb6f97278) = 12607
  96. set_robust_list(0xb6f97280,0xc) = 0
  97. futex(0xbece6778,FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME,1,NULL,b6d8c000) = -1 EAGAIN (Resource temporarily unavailable)
  98. rt_sigaction(SIGRTMIN,{0xb6d7520c,[],SA_SIGINFO|0x4000000},8) = 0
  99. rt_sigaction(SIGRT_1,{0xb6d750b4,SA_RESTART|SA_SIGINFO|0x4000000},8) = 0
  100. rt_sigprocmask(SIG_UNBLOCK,[RTMIN RT_1],8) = 0
  101. getrlimit(RLIMIT_STACK,{rlim_cur=8192*1024,rlim_max=RLIM_INFINITY}) = 0
  102. rt_sigaction(SIGFPE,{SIG_IGN,[FPE],SA_RESTART|0x4000000},{SIG_DFL,0},8) = 0
  103. brk(0) = 0xd98000
  104. brk(0xdb9000) = 0xdb9000
  105. getuid32() = 1001
  106. geteuid32() = 1001
  107. getgid32() = 1004
  108. getegid32() = 1004
  109. open("/usr/lib/locale/locale-archive",O_RDONLY|O_LARGEFILE) = 3
  110. fstat64(3,st_size=1534656,1534656,0) = 0xb6a66000
  111. close(3) = 0
  112. open("/dev/urandom",O_RDONLY|O_LARGEFILE) = 3
  113. read(3,"~\210\223\234",4) = 4
  114. close(3) = 0
  115. gettimeofday({1460938704,307768},NULL) = 0
  116. readlink("/proc/self/exe","/usr/bin/perl",4095) = 13
  117. stat64("/usr/local/lib/site_perl/5.14.2/arm-linux-gnueabihf-thread-multi-64int",0xbece6368) = -1 ENOENT (No such file or directory)
  118. stat64("/usr/local/lib/site_perl/5.14.2",0xbece6368) = -1 ENOENT (No such file or directory)
  119. stat64("/usr/local/lib/site_perl/arm-linux-gnueabihf-thread-multi-64int",0xbece6368) = -1 ENOENT (No such file or directory)
  120. open("./response",O_RDONLY|O_LARGEFILE) = 3
  121. ioctl(3,SNDCTL_TMR_TIMEBASE or TCGETS,0xbece627c) = -1 ENOTTY (Inappropriate ioctl for device)
  122. _llseek(3,[0],SEEK_CUR) = 0
  123. fcntl64(3,F_SETFD,FD_CLOEXEC) = 0
  124. rt_sigaction(SIGCHLD,8) = 0
  125. brk(0xddb000) = 0xddb000
  126. read(3,"#!/usr/bin/perl\nuse warnings;\nus"...,8192) = 210
  127. stat64("/etc/perl/warnings.pmc",0xbece5e10) = -1 ENOENT (No such file or directory)
  128. stat64("/etc/perl/warnings.pm",0xbece5d90) = -1 ENOENT (No such file or directory)
  129. stat64("/usr/local/lib/perl/5.14.2/warnings.pmc",0xbece5e10) = -1 ENOENT (No such file or directory)
  130. stat64("/usr/local/lib/perl/5.14.2/warnings.pm",0xbece5d90) = -1 ENOENT (No such file or directory)
  131. stat64("/usr/local/share/perl/5.14.2/warnings.pmc",0xbece5e10) = -1 ENOENT (No such file or directory)
  132. stat64("/usr/local/share/perl/5.14.2/warnings.pm",0xbece5d90) = -1 ENOENT (No such file or directory)
  133. stat64("/usr/lib/perl5/warnings.pmc",0xbece5e10) = -1 ENOENT (No such file or directory)
  134. stat64("/usr/lib/perl5/warnings.pm",0xbece5d90) = -1 ENOENT (No such file or directory)
  135. stat64("/usr/share/perl5/warnings.pmc",0xbece5e10) = -1 ENOENT (No such file or directory)
  136. stat64("/usr/share/perl5/warnings.pm",0xbece5d90) = -1 ENOENT (No such file or directory)
  137. stat64("/usr/lib/perl/5.14/warnings.pmc",0xbece5e10) = -1 ENOENT (No such file or directory)
  138. stat64("/usr/lib/perl/5.14/warnings.pm",0xbece5d90) = -1 ENOENT (No such file or directory)
  139. stat64("/usr/share/perl/5.14/warnings.pmc",0xbece5e10) = -1 ENOENT (No such file or directory)
  140. stat64("/usr/share/perl/5.14/warnings.pm",st_size=15015,...}) = 0
  141. open("/usr/share/perl/5.14/warnings.pm",O_RDONLY|O_LARGEFILE) = 4
  142. ioctl(4,0xbece5be4) = -1 ENOTTY (Inappropriate ioctl for device)
  143. _llseek(4,SEEK_CUR) = 0
  144. read(4,"# -*- buffer-read-only: t -*-\n# "...,8192) = 8192
  145. read(4,"08\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x"...,8192) = 6823
  146. read(4,"",8192) = 0
  147. close(4) = 0
  148. brk(0xdfc000) = 0xdfc000
  149. stat64("/etc/perl/strict.pmc",0xbece5e10) = -1 ENOENT (No such file or directory)
  150. stat64("/etc/perl/strict.pm",0xbece5d90) = -1 ENOENT (No such file or directory)
  151. stat64("/usr/local/lib/perl/5.14.2/strict.pmc",0xbece5e10) = -1 ENOENT (No such file or directory)
  152. stat64("/usr/local/lib/perl/5.14.2/strict.pm",0xbece5d90) = -1 ENOENT (No such file or directory)
  153. stat64("/usr/local/share/perl/5.14.2/strict.pmc",0xbece5e10) = -1 ENOENT (No such file or directory)
  154. stat64("/usr/local/share/perl/5.14.2/strict.pm",0xbece5d90) = -1 ENOENT (No such file or directory)
  155. stat64("/usr/lib/perl5/strict.pmc",0xbece5e10) = -1 ENOENT (No such file or directory)
  156. stat64("/usr/lib/perl5/strict.pm",0xbece5d90) = -1 ENOENT (No such file or directory)
  157. stat64("/usr/share/perl5/strict.pmc",0xbece5e10) = -1 ENOENT (No such file or directory)
  158. stat64("/usr/share/perl5/strict.pm",0xbece5d90) = -1 ENOENT (No such file or directory)
  159. stat64("/usr/lib/perl/5.14/strict.pmc",0xbece5e10) = -1 ENOENT (No such file or directory)
  160. stat64("/usr/lib/perl/5.14/strict.pm",0xbece5d90) = -1 ENOENT (No such file or directory)
  161. stat64("/usr/share/perl/5.14/strict.pmc",0xbece5e10) = -1 ENOENT (No such file or directory)
  162. stat64("/usr/share/perl/5.14/strict.pm",st_size=879,...}) = 0
  163. open("/usr/share/perl/5.14/strict.pm","package strict;\n\n$strict::VERSIO"...,8192) = 879
  164. _llseek(4,878,[878],SEEK_SET) = 0
  165. _llseek(4,SEEK_CUR) = 0
  166. close(4) = 0
  167. read(3,8192) = 0
  168. open("file.txt",O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE,0666) = 4
  169. ioctl(4,0xbece614c) = -1 ENOTTY (Inappropriate ioctl for device)
  170. _llseek(4,SEEK_CUR) = 0
  171. fstat64(4,st_size=0,...}) = 0
  172. fcntl64(4,FD_CLOEXEC) = 0
  173. rt_sigaction(SIG_0,{0xb6e18dc4,[TRAP RTMIN RT_1 RT_2 RT_3 RT_12 RT_13 RT_15 RT_16 RT_18 RT_19 RT_20 RT_25 RT_26 RT_27 RT_28 RT_29],SA_SIGINFO|0x85b8},8) = -1 EINVAL (Invalid argument)
  174. rt_sigaction(SIGHUP,8) = 0
  175. rt_sigaction(SIGINT,8) = 0
  176. rt_sigaction(SIGQUIT,8) = 0
  177. rt_sigaction(SIGILL,8) = 0
  178. rt_sigaction(SIGTRAP,8) = 0
  179. rt_sigaction(SIGABRT,8) = 0
  180. rt_sigaction(SIGBUS,8) = 0
  181. rt_sigaction(SIGFPE,8) = 0
  182. rt_sigaction(SIGKILL,8) = 0
  183. rt_sigaction(SIGUSR1,8) = 0
  184. rt_sigaction(SIGSEGV,8) = 0
  185. rt_sigaction(SIGUSR2,8) = 0
  186. rt_sigaction(SIGPIPE,8) = 0
  187. rt_sigaction(SIGALRM,8) = 0
  188. rt_sigaction(SIGTERM,8) = 0
  189. rt_sigaction(SIGSTKFLT,8) = 0
  190. rt_sigaction(SIGCHLD,8) = 0
  191. rt_sigaction(SIGCONT,8) = 0
  192. rt_sigaction(SIGSTOP,8) = 0
  193. rt_sigaction(SIGTSTP,8) = 0
  194. rt_sigaction(SIGTTIN,8) = 0
  195. rt_sigaction(SIGTTOU,8) = 0
  196. rt_sigaction(SIGURG,8) = 0
  197. rt_sigaction(SIGXcpu,8) = 0
  198. rt_sigaction(SIGXFSZ,8) = 0
  199. rt_sigaction(SIGVTALRM,8) = 0
  200. rt_sigaction(SIGPROF,8) = 0
  201. rt_sigaction(SIGWINCH,8) = 0
  202. rt_sigaction(SIGIO,8) = 0
  203. rt_sigaction(SIGPWR,8) = 0
  204. rt_sigaction(SIGSYS,8) = 0
  205. rt_sigaction(SIGRT_2,8) = 0
  206. rt_sigaction(SIGRT_3,8) = 0
  207. rt_sigaction(SIGRT_4,8) = 0
  208. rt_sigaction(SIGRT_5,8) = 0
  209. rt_sigaction(SIGRT_6,8) = 0
  210. rt_sigaction(SIGRT_7,8) = 0
  211. rt_sigaction(SIGRT_8,8) = 0
  212. rt_sigaction(SIGRT_9,8) = 0
  213. rt_sigaction(SIGRT_10,8) = 0
  214. rt_sigaction(SIGRT_11,8) = 0
  215. rt_sigaction(SIGRT_12,8) = 0
  216. rt_sigaction(SIGRT_13,8) = 0
  217. rt_sigaction(SIGRT_14,8) = 0
  218. rt_sigaction(SIGRT_15,8) = 0
  219. rt_sigaction(SIGRT_16,8) = 0
  220. rt_sigaction(SIGRT_17,8) = 0
  221. rt_sigaction(SIGRT_18,8) = 0
  222. rt_sigaction(SIGRT_19,8) = 0
  223. rt_sigaction(SIGRT_20,8) = 0
  224. rt_sigaction(SIGRT_21,8) = 0
  225. rt_sigaction(SIGRT_22,8) = 0
  226. rt_sigaction(SIGRT_23,8) = 0
  227. rt_sigaction(SIGRT_24,8) = 0
  228. rt_sigaction(SIGRT_25,8) = 0
  229. rt_sigaction(SIGRT_26,8) = 0
  230. rt_sigaction(SIGRT_27,8) = 0
  231. rt_sigaction(SIGRT_28,8) = 0
  232. rt_sigaction(SIGRT_29,8) = 0
  233. rt_sigaction(SIGRT_30,8) = 0
  234. rt_sigaction(SIGRT_31,8) = 0
  235. rt_sigaction(SIGRT_32,8) = 0
  236. write(4,"Here's some text\n",17) = 17
  237. close(4) = 0
  238. close(3) = 0
  239. exit_group(0) = ?

关于为什么不产生产出的任何想法?一个bash脚本可以将文本回显为标准格式.

当我在调试模式下运行脚本时,它会打印输出.

在命令行执行perl -v后,退出代码从$?是0.

执行

  1. perl -e'print "foo" or die $!'

给出并退出9的代码,但这似乎是由于死亡. perl -v>文件没有写任何文件.

这是stat STDOUT的输出和用于将其写入文件的命令:

45826 | 261126 | 33188 | 1 | 1001 | 1004 | 0 | 0 | 1461024408 | 1461035504 | 1461035504 | 4096 | 0

  1. perl -e 'open my $FH,">file"; print $FH join "|",stat STDOUT '
开始阅读之前,先看看这个命令的输出.一切都指向STDOUT指向不正确的地方.
  1. ls -l /proc/$$/fd/{1,2}

在我的系统上,我得到这一点,请注意它会改变,因为我写这个,因为这不是一次写的.

  1. lrwx------ 1 root root 64 May 3 17:01 /proc/27806/fd/1 -> /dev/pts/1
  2. lrwx------ 1 root root 64 May 3 17:01 /proc/27806/fd/2 -> /dev/pts/1

我怀疑以上与你相似.这个统计数据对我来说看起来很可疑,如果我有机会访问我搜索inode的文件,它告诉我写给ie.

  1. sudo find / -printf "%i:\t%p\n"|grep 261126

如果Perl开始改变它是stdout等到错误的地方,我会添加一个很长的睡眠脚本,然后进行搜索,看看它在哪里.如果文件是普通文件,并且它在文件系统上,应该找到它.

我的STDOUT统计

  1. |dev |inode |mode |link |uid |gid |rdev |size |atime |mtime |ctime |blk |blka
  2. |13 |3 |8592 |1 |1000|5 |34816|0 |1462301986|1462301986|1462301958|1024|0

您的STDOUT统计

  1. |dev |inode |mode |link |uid |gid |rdev |size |atime |mtime |ctime |blk |blka
  2. |45826 |261126 |33188 |1 |1001|1004|0 |0 |1461024408|1461035504|1461035504|4096|0

在我的我的dev有小数13,看起来确定,当我在设备下搜索它.如果我们掩盖你的主要/未成年人你有…

  1. major == 179
  2. minor == 2

注意,我原来有这些相反,直到Wumpus Q. Wumbley修正.

在我的机器上

  1. crw------- 1 root root 2,179 Apr 29 12:50 ptya3

在我的我的rdev等于

  1. major == 136
  2. minor == 0

在我的Debian系统上,这是/ dev / pts / 0.你的rdev是0.我有一个快速的回顾,有些人使用屏幕可以有/ dev / pts / N的问题,即它不在那里,但这是我猜.

strace也很奇怪,当我在系统中写下来时,我得到了以下几行:

  1. read(3,"#!/usr/bin/perl -w\n#use strict;\n"...,8192) = 228
  2. read(3,8192) = 0
  3. close(3) = 0
  4. write(1,"Here's some text STDOUT\n",24Here's some text STDOUT
  5. ) = 24
  6. write(2,"Here's some text STDERR\n",24Here's some text STDERR
  7. ) = 24
  8. write(1,24Here's some text STDOUT
  9. ) = 24

事实上,这些似乎没有在你的战争中是非常奇怪的.你可以用$|来改变出现在哪里但他们应该出现在某个地方. Gilles注意到模式也是奇数.如果你运行这个脚本…

  1. #!/usr/bin/perl
  2. use warnings;
  3. use strict;
  4. use Fcntl ':mode';
  5. my $mode = 33188;
  6. my $user_rwx = ($mode & S_IRWXU) >> 6;
  7. print("user_rwx = $user_rwx\n");
  8. my $group_read = ($mode & S_IRGRP) >> 3;
  9. print("group_read = $group_read\n");
  10. my $other_execute = $mode & S_IXOTH;
  11. print("other_execute = $other_execute\n");
  12. printf "Permissions are %04o\n",S_IMODE($mode),"\n";
  13. my $is_setuid = $mode & S_ISUID;
  14. print("is_setuid = $is_setuid\n");
  15. my $is_directory = S_ISDIR($mode);
  16. print("dir = $is_directory\n");
  17. my $is_reg = S_ISREG($mode);
  18. print("regular = $is_reg\n");

您可以看到STDOUT似乎指向正常文件.这将确定为什么rdev为零,即如果stdout正在重定向到某个旨在成为设备的东西,但实际上只是一个正常的文件.我看到像这样的奇怪的事情发生在chrooted环境中,设备设置不正确.

不管在退出时打开还是关闭缓冲区,缓冲区都应该被刷新,即您会看到对调用sys的调用.在strace中完全没有写入是非常奇怪的.

猜你在找的Bash相关文章