简体   繁体   English

Bash-编译可加载的睡眠

[英]Bash - Compiling sleep loadable

I am trying to compile the sleep loadable that is included in the bash src tarball. 我正在尝试编译bash src tarball中包含的sleepable。

I have tried running the commands listed in post #7 of the following thread, 我已经尝试运行以下线程的帖子#7中列出的命令,

https://bbs.archlinux.org/viewtopic.php?pid=1366887#p1366887 https://bbs.archlinux.org/viewtopic.php?pid=1366887#p1366887

but I encounter errors when compiling the sleep command. 但是我在编译sleep命令时遇到错误。

This is the output I receive when I run make sleep : 这是我运行make sleep时收到的输出:

System:~/bash-4.0/examples/loadables root# make sleep
gcc -fno-common -DHAVE_CONFIG_H -DSHELL -DMACOSX -g -O2 -I. -I.. -I../.. -I../../lib -I../../builtins -I../../include -I/var/root/bash-4.0 -I/var/root/bash-4.0/lib -I/var/root/bash-4.0/builtins -I../../lib/intl -I/var/root/bash-4.0/lib/intl -c -o sleep.o sleep.c
gcc -dynamic   -o sleep sleep.o
Undefined symbols:
  "_main", referenced from:
      __start in crt1.10.5.o
  "_fsleep", referenced from:
      _sleep_builtin in sleep.o
  "_builtin_usage", referenced from:
      _sleep_builtin in sleep.o
  "_builtin_error", referenced from:
      _sleep_builtin in sleep.o
  "_uconvert", referenced from:
      _sleep_builtin in sleep.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make: *** [sleep] Error 1

Does anyone know how to get the bash sleep loadable to compile? 有谁知道如何加载bash sleep进行编译?

Thanks in advance. 提前致谢。

Update: 更新:

The source code was dowloaded from http://ftp.gnu.org/gnu/bash/bash-4.0.tar.gz . http://ftp.gnu.org/gnu/bash/bash-4.0.tar.gz下载了源代码。 It has not been modified. 尚未修改。

Why do I want to use the sleep loadable? 为什么我要使用sleepable load?

I have a couple programs that that wait for something to happen, then execute some code, and then wait again. 我有几个程序,它们等待某些事情发生,然后执行一些代码,然后再次等待。 I use the external sleep program to keep them from hogging processor time while looping. 我使用外部sleep程序来防止它们在循环时浪费处理器时间。 I wanted to use the sleep loadable to avoid creating the external sleep process. 我想使用可加载的sleep以避免创建外部sleep过程。 I have tried using the read command, but that won't work when I run my bash scripts as launchdaemons because there is no terminal. 我尝试使用read命令,但是当我将bash脚本作为启动守护程序运行时,该命令将不起作用,因为没有终端。 I have also tried using this read command solution ( https://unix.stackexchange.com/questions/68236/#68269 ), but bash only looped twice before freezing. 我也尝试使用此read命令解决方案( https://unix.stackexchange.com/questions/68236/#68269 ),但bash在冻结之前仅循环了两次。

My goal is to figure out some way to be able to sleep in bash without using an external program. 我的目标是想出一种无需使用外部程序就可以在bash中进行睡眠的方法。

First we would need to know where you got the source code from and exactly what you have done with it. 首先,我们需要知道您从何处获得源代码以及您对该源代码所做的确切操作。 iOS is based on BSD, not Linux, so archlinux instructions for compiling might not be that relevant. iOS基于BSD,而不基于Linux,因此archlinux的编译说明可能并不相关。 There is also the problem of iOS on the iPhone not actually being a full OS, but a sightly cutdown version. 还有一个问题,iPhone上的iOS并不是真正的完整操作系统,而是精简版。

Also, telling us what is the reason behind wanting sleep, we could possibly offer an alternative. 另外,告诉我们想要睡眠的原因是什么,我们可能会提供另一种选择。 For example if you have read, this should work (is sleep for 5.5 seconds): read -t 5.5 -N 0. 例如,如果您已阅读,这应该可以工作(睡眠5.5秒):读-t 5.5 -N 0。

Some also use ping to non-existent IP with a X seconds timeout. 有些人还使用ping到X秒超时的不存在的IP。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM