ipc

boost process running() and exit_code() thread safety

ぐ巨炮叔叔 提交于 2020-01-05 08:55:11
问题 I am using boost::process::child and boost::process::async_pipe to start an application and read asynchronously (through the means of boost::asio ) everything that app outputs on screen whenever this happens. I want to check also if the application is alive by using child::running() method; if not running I'd like to read the exit code using child::exit_code . This is very useful ESPECIALLY as it is a way to be notified about an application crashing or exiting unexpectedly (I could not find a

Running command in existing shell from gvim

最后都变了- 提交于 2020-01-05 07:24:19
问题 It all starts from a shell. For example I am using urxvt with zsh . There I open some file with gvim . In this case it is a LaTeX file. Now I need to execute some command (for compiling the document, e.g. pdflatex ). How can I have the original shell, from where gvim was started, execute that command? It would also be acceptable if gvim had to open a new shell once and after that execute every future call of the designated command ( pdflatex ) in that shell, while I can still type in it

Android开发的艺术探索第二章

百般思念 提交于 2020-01-04 14:21:08
IPC机制 2.1 Android IPC简介 IPC是Inter-Process Communication的缩写,含义为进程间通信或者跨进程通信,是指 两个进程之间进行数据交换的过程。 IPC不是Android中所独有的,任何一个操作系统都需要有相应的IPC机制,比如 Windows上可以通过剪贴板、管道和邮槽等来进行进程间通信;Linux上可以通过命名管 道、共享内容、信号量等来进行进程间通信。可以看到不同的操作系统平台有着不同的进 程间通信方式,对于Android来说,它是一种基于Linux内核的移动操作系统,它的进程间 通信方式并不能完全继承自Linux,相反,它有自己的进程间通信方式。在Android中最有 特色的进程间通信方式就是Binder了,通过Binder可以轻松地实现进程间通信。除了 Binder,Android还支持Socket,通过Socket也可以实现任意两个终端之间的通信,当然同 一个设备上的两个进程通过Socket通信自然也是可以的。 2.2 Android中的多进程模式 通过给四 大组件指定android:process属性,我们可以轻易地开启多进程模式,这看起来很简单,但 是实际使用过程中却暗藏杀机,多进程远远没有我们想的那么简单,有时候我们通过多进 程得到的好处甚至都不足以弥补使用多进程所带来的代码层面的负面影响。 2.2.1 开启多进程模式

Background process redirect to COPROC

喜夏-厌秋 提交于 2020-01-04 11:04:28
问题 In the following test script I run an elementary coprocess to which the echo built-in, run in background, attaches its standard-output: #!/bin/bash # TEST 1 coproc /bin/sleep 100 echo >&${COPROC[1]} & The script always fails, for no apparent reason, giving the output: ./test.sh: line 4: ${COPROC[1]}: Bad file descriptor I wonder if the correct syntax should be rather this one (ampersand moved before redirection): #!/bin/bash # TEST 2 coproc /bin/sleep 100 echo & >&${COPROC[1]} This second

synchronization between processes using unnamed semaphores

雨燕双飞 提交于 2020-01-04 05:55:44
问题 In process-1 I am trying to write the data into shared memory. At the same time in process-2 I am reading the data from the same shared memory. in this case I need to provide synchronization between these two processes. if I will go through unnamed semaphores (using shm_init(),mmap() ),will it work or not? I have written code like this will it work or not? fd = shm_open("shm_name", O_CREAT| O_RDWR, S_IRUSR | S_IWUSR); sema = mmap(NULL, sizeof(sem_t), PROT_READ | PROT_WRITE,MAP_SHARED , fd, 0)

Reading from a handle obtained outside createProcess

允我心安 提交于 2020-01-04 04:10:15
问题 I'm trying to create a process, and communicate with it via a handle that I provide outside the createProcess function: stdOutH <- openFile (logDir </> "stdout.log") ReadWriteMode hSetBuffering stdOutH LineBuffering (_, _, _, ph) <- createProcess $ (proc "someproc" []) { std_out = UseHandle stdOutH , std_err = UseHandle stdErrH } line <- hGetLine stdOutH putStrLn $ "Got " ++ line The "someproc" process spits a line out to the standard output, and I want to read it from the process that

What's the proper way to fork() in FastCGI?

半世苍凉 提交于 2020-01-04 02:48:10
问题 I have an app running under Catalyst+FastCGI. And I want it to fork() to do some work in background. I used this code for plain CGI long ago (and it worked): defined(my $pid = fork) or die "Can't fork: $!"; if ($pid) { # produce some response exit 0; } die "Can't start a new session: $!" if setsid == -1; close STDIN or die $!; close STDOUT or die $!; close STDERR or die $!; # do some work in background I tried some variations on this under FastCGI but with no success. How should forking be

Android: startActivityForResult not calling onActivityResult

纵饮孤独 提交于 2020-01-03 18:55:29
问题 My Setup A Service running in its own process, CentralService An activity that calls startActivityForResult(), MainActivity The activity that is being started for result, ReturnResultActivity What I'm trying to do Start ReturnResultActivity and have it bind to the service (register its handler) Let whatever other activities want to run run When it receives a message from the service: Unbind from the Service finish() setResult() Have the MainActivity's onActivityResult() method called Using

Android跨进程通信篇

女生的网名这么多〃 提交于 2020-01-03 05:17:12
前言 转载请声明,转自【https://www.cnblogs.com/andy-songwei/p/10256379.html】,谢谢! 只要是面试高级工程师岗位,Android跨进程通信就是最受面试官青睐的知识点之一。Android系统的运行由大量相互独立的进程相互协助来完成的,所以Android进程间通信问题,是做好Android开发高级工程师必须要跨过的一道坎。但是,我们是否真的清楚,Android中都有哪些方式实现跨进程通信呢?这些方式都有哪些优缺点?如何选择这些通信方式?Binder是什么?为什么要引入Binder?Binder是这么样实现跨进程通信的?AIDL是什么?AIDL和Binder又有什么关系呢?...... 本文将对Android的跨进程通、进程内通信等方面做一些总结,以及比较详细地介绍AIDL的使用,主要内容如下: 其行文脉络大致如下,希望能加深读者对这方面内容的记忆:(1)Android基于Linux系统,所以先说系统进程相关知识和Linux IPC。(2)总结Android的IPC,顺带总结了Android进程内组件之间的通信方式。(3)Android为了克服Linux IPC中的缺点,引入了Binder,所以对Binder做了一些宏观上的介绍。(4)AIDL是实现Binder最常用的工具,所以详细介绍了AIDL相关内容。 一、基础知识简介

InterProcess Communication on MacOSX Lion

℡╲_俬逩灬. 提交于 2020-01-03 03:43:08
问题 I'm trying to figure out how to set up IPC between my custom app and a pre-made program. I'm using MacOSX Lion 10.7.2 and Xcode 4.2.1. It doesn't matter actually what program exactly, since I believe that a similar reasoning may be applied to any kind of external process. For testing purposes I'm using a simple bash script: #test.sh echo "Starting" while read out do echo $out done What I would like to achieve is to redirect input and output of this script, using my app to send inputs to it