`pthread_create`的`pthread_t *`参数需要多长时间才能存活?(How long does the `pthread_t*` argument to `pthread_create` need to survive?)
pthread_create(3)
的签名是:int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine) (void *), void *arg);
pthread_t *thread
参数的存储持续时间有哪些要求?pthread_create
的手册页说:在返回之前,成功调用
pthread_create()
会将新线程的ID存储在线程指向的缓冲区中;但是不清楚它是否意味着它将值存储在那里以便调用者可以检查它,或者它是否使用该缓冲区来存储值(暗示缓冲区需要在子线程的整个生命周期内保持可用)。
同样,
pthread_self
说它返回创建此线程的
pthread_create(3)
调用中*thread
中返回的相同值。但是不清楚它是否意味着它返回存储在
*thread
的值或者等于*thread
返回的值 。具体来说,我想知道这样的事情是否合法:
void make_thread(void) { pthread_t tid; return pthread_create(&tid, NULL, some_fn, NULL); }
或者如果
tid
需要是malloc
。 当我把tid
放在堆栈上时,我在与_Unwind_ForcedUnwind
相关的valgrind中得到了一堆错误,这让我怀疑*thread
需要在子线程的生命周期内保持有效。The signature of
pthread_create(3)
is:int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine) (void *), void *arg);
What are the requirements on the storage duration of the
pthread_t *thread
argument? The man page forpthread_create
says:Before returning, a successful call to
pthread_create()
stores the ID of the new thread in the buffer pointed to bythread
;But it's not clear if it means that it stores the value there so that the caller can examine it, or if it uses that buffer to store the value (implying that the buffer needs to stay usable for the whole lifetime of the child thread).
Similarly,
pthread_self
says it returnsthe same value that is returned in
*thread
in thepthread_create(3)
call that created this thread.but it's not clear if it means that it returns the value stored in
*thread
or a value equal to what was returned in*thread
.Concretely, I'm wondering if it's legal to have something like:
void make_thread(void) { pthread_t tid; return pthread_create(&tid, NULL, some_fn, NULL); }
or if
tid
needs to bemalloc
'd. When I puttid
on the stack, I get a bunch of errors in valgrind related to_Unwind_ForcedUnwind
, which makes me suspect that*thread
needs to remain valid for the lifetime of the child thread.
原文:https://stackoverflow.com/questions/35928654
最满意答案
这是c#绑定的答案,我猜你正在使用java绑定,但它应该几乎相同。
首先,您应该使用此处的selenium-server-standalone-2.0b3.jar在远程selenium服务器上启动selenium服务器: http : //code.google.com/p/selenium/downloads/list
你开始使用:
java -jar selenium-server-standalone-2.0b3.jar
在您的测试中,您使用RemoteWebDriver,如下所示:
var desiredCapabilities = DesiredCapabilities.Firefox(); var selenium = new RemoteWebDriver(new Uri("http://seleniumserver1:4444/wd/hub"), desiredCapabilities);
这应该确保您的测试脚本将所有webdriver命令发送到远程服务器。
Grid 2.0应该在selenium 2.0 beta 4中,这样可以更容易地使用两个selenium服务器。 (我猜你现在可以自己切换服务器网址)
This is an answer for the c# bindings, I guess you're using the java bindings but it should almost be the same.
First you should start the selenium server on the remote selenium server using the selenium-server-standalone-2.0b3.jar found here: http://code.google.com/p/selenium/downloads/list
You start it using:
java -jar selenium-server-standalone-2.0b3.jar
In your test you use the RemoteWebDriver like this:
var desiredCapabilities = DesiredCapabilities.Firefox(); var selenium = new RemoteWebDriver(new Uri("http://seleniumserver1:4444/wd/hub"), desiredCapabilities);
That should make sure your testscripts send all webdriver commands to the remote server.
Grid 2.0 should be in selenium 2.0 beta 4 making it easier to use both selenium servers. ( I guess now you could switch server urls by yourself )
相关问答
更多-
如果不运行X服务器,是否可以运行Selenium脚本?(Is it possible to run Selenium scripts without having an X server running, too?)[2021-11-20]
是的,您需要运行X服务器,因为Selenium需要运行浏览器,并且浏览器需要某种X服务器才能运行。 幸运的是,有许多类型的X服务器,其中之一是Xvfb又名X虚拟帧缓冲区,它执行内存中的所有操作,因此不需要屏幕。 维基百科也有一些很好的例子 。 关于headless , xvfb和selenium关键字,还有很多关于SO的问题。 做出明智的选择 ;) [编辑] : 这是一个很好的例子 。 Yes, you need to have X server running because Selenium requi ... -
你的意思是Selenium WebDriver? 呵呵.... 先决条件 :根据您的操作系统安装Python 安装以下命令 pip install -U selenium 并在你的代码中使用这个模块 from selenium import webdriver 您还可以根据需要使用许多以下内容 from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import Select from selenium ...
-
您可以从命令行运行ide测试: http : //www.seleniumhq.org/docs/05_selenium_rc.jsp#running-selenium-server 使用htmlSuite选项: https ://wiki.mozilla.org/Running_IDE_scripts_with_Selenium_RC 然后你可以使用cron作业从命令行运行它,或者你可以使用Jenkins插件: https : //wiki.jenkins-ci.org/display/JENKINS/S ...
-
解决方案:AutoITx.jar。 在selenium中导入jar并直接在selenium web驱动中使用autoit脚本。 The solution: AutoITx.jar. import the jar in selenium and directly use the autoit script in selenium web driver.
-
是否有可能使用谷歌计算引擎运行硒脚本?(Is it possible to run selenium scripts using google compute engine?)[2022-05-30]
唯一的区别是你的GCE实例没有显示,这对你的浏览器来说是个问题。 为了解决这个问题,你需要使用“Virtual Framebuffer”来运行Selenium。 这基本上是一个“假显示”。 以下是在Ubuntu中设置虚拟帧缓冲区的方法: sudo apt-get install xvfb sudo Xvfb :10 -ac 然后,在开始你的硒脚本之前,运行: export DISPLAY=:10 The only difference is that your GCE instance doesn't ... -
如何使用Selenium Server运行Selenium IDE测试(How to run a Selenium IDE test using Selenium Server)[2023-01-04]
IDE生成的文件可以与服务器一起运行。 java -jar“[Selenium服务器.jar文件的路径]”-htmlSuite“* [浏览器,请参阅此处的列表 ]”“[浏览器将在启动时导航到的URL]”“[HTML测试套件文件的路径在IDE中制作“”[服务器将写入的HTML结果文件的路径]“ 本页讨论了这个进一步阅读的过程 。 The files generated by the IDE can be run with the server. java -jar "[path to the Selenium ... -
因此,我们最终通过Atlassian Bamboo使用ANT脚本来完成这项工作。 我们正在部署Bamboo以进行其他维护并构建问题。 然而,从我所做的研究来看,看起来Jenkins-CI(以前的Hudson-CI)是一个可以做同样事情或非常相似的自由选项。 So we ended up using an ANT script through Atlassian Bamboo to get this job done. We were deploying Bamboo for other maintenanc ...
-
通过SSH远程运行脚本(Run scripts remotely via SSH)[2023-02-10]
由于您需要登录远程计算机,因此AFAICT无法做到这一点“没有ssh”。 但是, ssh接受一个在远程机器上执行的命令(而不是启动的shell)。 因此,如果您可以将脚本保存在远程机器上,例如〜/ script.sh,则可以在不启动交互式shell的情况下执行它 $ ssh remote_machine ~/script.sh 一个脚本终止连接将被自动关闭(如果你没有故意配置)。 Since you need to log into the remote machine there is AFAICT n ... -
一个想法。 您可以创建一个结合Jenkins / Selenium / Amazon的基础设施。 以下是来自另一篇文章的解决方案。 你可以用网格来完成。 首先,您需要创建一个带有EC2 ubuntu 14.04 AMI的Selenium hub,无需UI,并将其作为jenkins slave连接到Jenkins master。 或者直接成为主人。 你想要什么。 只有命令行。 单独下载Selenium Server。 (下载版本时要小心。如果下载Selenium3Beta,事情可能会发生变化)。 在这里你可以 ...
-
这是c#绑定的答案,我猜你正在使用java绑定,但它应该几乎相同。 首先,您应该使用此处的selenium-server-standalone-2.0b3.jar在远程selenium服务器上启动selenium服务器: http : //code.google.com/p/selenium/downloads/list 你开始使用: java -jar selenium-server-standalone-2.0b3.jar 在您的测试中,您使用RemoteWebDriver,如下所示: var des ...