process

Passing data from Java process to a python script

青春壹個敷衍的年華 提交于 2020-04-30 06:42:31
问题 I call a external Python script as Java process and want to send data to this. I create a process and try to send a string. Later the python script should wait for a new input from Java, work with this data and wait again(while true loop). Python Code (test.py): input = input("") print("Data: " + input) Java Code: Process p = Runtime.getRuntime().exec("py ./scripts/test.py"); BufferedWriter out = new BufferedWriter(new OutputStreamWriter(p.getOutputStream())); BufferedReader stdInput = new

Pipe commands with fork and dup2

≯℡__Kan透↙ 提交于 2020-04-18 03:57:11
问题 I wrote the following code in order to pipe two commands: #include <stdlib.h> #include <unistd.h> char *program_1[3] = {"/bin/cat", "/dev/random", NULL}; char *program_2[2] = {"/bin/ls", NULL}; char *program_3[2] = {"/usr/bin/sort", NULL}; int main(void) { int fd[2]; int pid; pipe(fd); if ((pid = fork()) == 0) //Child process { dup2(fd[1], STDOUT_FILENO); close(fd[0]); execve(program_3[0], program_3, NULL); } else if (pid > 0) //Parent process { dup2(fd[0], STDIN_FILENO); close(fd[1]); execve

Draw process tree with gnuplot

岁酱吖の 提交于 2020-04-11 08:30:13
问题 similar to this question here I want to draw process tree where a PID is given, I should be able to draw that process and its children as a tree. However, I want to preserve parent children relationship between nodes/edges. What I mean is, any two children should not have edge between. Coordinates actually do not matter. Also, I am open for other drawing tool options. I tried the accepted answer of mentioned question but it links all nodes. Any kind of suggestion/help would make my day. Note:

[Erlang 0051] Using ETS in Erlang Shell

二次信任 提交于 2020-04-01 20:07:52
在Erlang Shell中调试的时候经常会遇到的一个问题就是在Shell中遇到异常会导致ETS表丢失,需要反复去创建ETS表,调试比较麻烦.这是由于Erlang Shell在遇到异常之后会重建,ETS表依赖于创建它的进程,如果创建它的进程崩溃了ETS表也就销毁了(不是绝对的,后面可以看到);看下官方文档的描述: Note that there is no automatic garbage collection for tables. Even if there are no references to a table from any process,it will not automatically be destroyed unless the owner process terminates.It can be destroyed explicitly by using delete/1.The default owner is the process that created the table. 我们先来解决这个Erlang Shell调试的问题,首先一个很简单的方法就是解除对Shell进程的依赖,我们在别的进程里面创建ETS表. Eshell V5.9 (abort with ^G)1> ets:new(test,[named_table]). %%%

不重复启动程序

不羁岁月 提交于 2020-04-01 04:27:59
1 static class Program 2 { 3 /// <summary> 4 /// アプリケーションのメイン エントリ ポイントです。 5 /// </summary> 6 [STAThread] 7 static void Main() 8 { 9 Process instance = RunningInstance(); 10 if (instance == null) 11 { 12 //启用可视样式 13 Application.EnableVisualStyles(); 14 //在应用程序范围内设置控件显示文本的默认方式(可以设为使用新的GDI+ , 还是旧的GDI) 15 //true使用GDI+方式显示文本, 16 //false使用GDI方式显示文本. 17 Application.SetCompatibleTextRenderingDefault(false); 18 //在当前线程上开始运行标准应用程序消息循环,并使指定窗体可见 19 Application.Run(new _1_02_Menu()); 20 } 21 else 22 { 23 // 二重起動はできません。 24 string strMessage = Msg.GetMessageInfo("---", ""); 25 MessageBox.Show(strMessage, "-

QPM-PHP进程管理框架

喜欢而已 提交于 2020-03-27 17:14:33
3 月,跳不动了?>>> QPM全名是 Quick Process Management Framework for PHP. PHP 是强大的web开发语言,以至于大家常常忘记PHP 可以用来开发健壮的命令行(CLI)程序以至于daemon程序。 而编写daemon程序免不了与各种进程管理打交道。QPM正是为简化进程管理而开发的类库。 QPM的项目地址是: https://github.com/Comos/qpm 以下是用QPM编写多进程程序的小例子。 //定义 mission1:每隔3秒打印一次进程信息, 无限循环。 $mission1 = function() { while(true) { echo "---mission 1, pid:".posix_getpid()."\n"; sleep(3); } }; //定义 mission2:打印信息后 3秒后退出。 $mission2 = function() { echo "+++mission 2,pid:".posix_getpid()."\n"; sleep(3); }; //配置: mission 1 和mission 2 同时在子进程中执行。mission 1 只允许在一个子进程中执行,mission 2 则允许2个子进程并行执行。 $config = [ ['runnableCallback'=>

进程

天涯浪子 提交于 2020-03-25 19:06:15
#开启进程方式1 from multiprocessing import Process import time def work(name): print("target %s is running" %name) time.sleep(2) print("target %s is done" %name) if __name__=="__main__": p1=Process(target=work,args=("egon",)) p2=Process(target=work,args=("alex",)) p1.start()#向操作系统发送请求,开启进程 p2.start() print("主进程") ''' 主进程 target egon is running target alex is running target alex is done target egon is done ''' #开启进程方式2 from multiprocessing import Process import time class MyProcess(Process): def __init__(self,name): super().__init__() self.name=name def run(self): print("target %s is running" %self

Powershell : Get-Process does not enumerate all process modules

蓝咒 提交于 2020-03-23 07:49:23
问题 There are some process modules that I am getting error for, like permission denied and cannot enumerate for processes like Services, Idle, csrss. It appears there are processes whose modules fundamentally cannot be enumerated due to lack of permissions, even when running with elevation (as admin). How and what permission need to be obtained to be able to enumerate these processes. Cmdlet executed: Invoke-Command -Session $session -ScriptBlock { Get-Process -Module } and for local just Get

capture error from runtime process java

微笑、不失礼 提交于 2020-03-23 04:05:53
问题 I'm running a Java program from another Java application using Runtime.getRuntime().exec like this Process p1 = Runtime.getRuntime().exec("javac test.java"); Process p2 = Runtime.getRuntime().exec("java test"); The content of the test.java import java.io.*; class test { public static void main(String args[]) { Scanner sc = new Scanner(System.in); String s = sc.nextLine(); System.out.println(s); } } I want to handle Input , Output and Error stream of the process p2 . I did capture of the