I've been trying to find out how to use PhantomJS's child process module, but documentation is very scarce: http://phantomjs.org/api/child_process/
Where can I find more documentation on how to use the child process module? The API only documents the spawn command. How do I use execFile and kill? Are these all the methods there are? What does communicate with them via stdin / stdout / stderr mean?
Related
I want to extract execution traces (e.g., visited basic blocks) when testing Apache server (httpd). Since my work is based on LLVM infrastructure, I choose to use clang instrumentation based profiling as follows:
clang -fprofile-instr-generate ${options to compile httpd} -o httpd
export LLVM_PROFILE_FILE=code-%p.profraw
sudo -E ./httpd -k start # output a .profraw
curl ${url} # send a request
sudo -E ./httpd -k stop # output another .profraw
The compilation of instrumented httpd works well.
However, I want to track httpd's request handling which is executed in a separate child process. The output .profraw does not record any execution from child processes. As a result, I can only access the execution traces of starting and closing the server. How can I get the .profraw including request handling?
Not restricted in clang profiling. Any solution compatible with LLVM is great. Thanks!
Update
From the logs, it turns out the child process whose owner is "daemon" has no write permission to the files
LLVM Profile Error: Failed to write file "code-94752.profraw": Permission denied
Problem solved
The problem is the collision of prof file names. The process httpd -k start create multiple child processes as workers. When using LLVM_PROFILE_FILE=code-%p.profraw, their pid %p is same. So the main process is owned by root and creates the prof file first. Then latter process owned by daemon cannot write that file.
Solution: Use LLVM_PROFILE_FILE=code-%9m.profraw (%Nm instead of %p) to avoid name collisions.
I've installed OTP using IntelliJ IDEA. I downloaded GTFS and OSM data from Berlin and I create a main configuration to build the graph and the server. Once I run it, it gives me the following warnings:
15:26:18.781 INFO (Graph.java:805) Main graph size: |V|=844791 |E|=1965688 15:26:18.781 INFO (Graph.java:806) Writing graph C:\Users\paula\Desktop\berlindata\Graph.obj ... 15:26:32.793 INFO (Graph.java:844) Graph written. 15:26:32.889 INFO (GraphBuilder.java:171) Graph building took 4,4 minutes. 15:26:32.891 INFO (GraphScanner.java:81) Attempting to automatically register routerIds [route] 15:26:32.891 INFO (GraphScanner.java:82) Graph files will be sought in paths relative to C:\Users\paula\Desktop\berlindata\graphs 15:26:32.893 INFO (GraphService.java:189) Registering new router 'route' 15:26:32.893 WARN (InputStreamGraphSource.java:218) Graph file not found or not openable for routerId 'route': java.io.FileNotFoundException: C:\Users\paula\Desktop\berlindata\graphs\route\Graph.obj (El sistema no puede encontrar la ruta especificada) 15:26:32.893 WARN (InputStreamGraphSource.java:144) Unable to load data for router 'route'. 15:26:32.893 WARN (GraphService.java:198) Can't register router ID 'route', no graph. 15:26:32.909 INFO (GrizzlyServer.java:50) Starting OTP Grizzly server on ports 8080 (HTTP) and 8081 (HTTPS) of interface 0.0.0.0 15:26:32.909 INFO (GrizzlyServer.java:52) OTP server base path is C:\Users\paula\Desktop\berlindata 15:26:33.994 WARN (PropertiesHelper.java:330) There is no way how to transform value "true" [java.lang.Boolean] to type [java.lang.String]. 15:26:34.088 INFO (NetworkListener.java:750) Started listener bound to [0.0.0.0:8080] 15:26:34.151 INFO (NetworkListener.java:750) Started listener bound to [0.0.0.0:8081] 15:26:34.151 INFO (HttpServer.java:300) [HttpServer] Started. 15:26:34.151 INFO (GrizzlyServer.java:130) Grizzly server running.
I think my problem is that I'm not writing properly the program arguments. I wrote that:
program arguments
Do you know what I should change?
Thank you
When you add the "--router route" parameter to the OpenTripPlanner arguments, once the graphs are built OpenTripPlanner will search for a folder called "route" in the <basePath>\graphs\ folder.
Because you are building the graphs in the basePath folder, you should be able to add the argument "--autoScan" and remove the argument "--router route" and OpenTripPlanner should pick detect the Graph.obj file automatically.
Alternatively, you can move the "Graph.obj" to a folder called <basePath>\graphs\route and keep the arguments as they are. Keep in mind though, every time you run that command it will rebuild the OpenTripPlanner Graph.obj file, but load the graph in the <basePath>\graphs\route folder. I personally run two separate commands: one to build the OpenTripPlanner graph, and another to start the OpenTripPlanner server with the graph created in the previous step.
The OpenTripPlanner documentation should give you some advice, as well as using the "--help" argument into OpenTripPlanner.
command = "libreoffice5.0 --headless --convert-to odt /data/Format/000001535edbaf8f27a9c331003600c900520045/test.docx --outdir /data/Format/000001535edbaf8f27a9c331003600c900520045"
When we run this command on terminal that gives me output
/data/Format/000001535edbaf8f27a9c331003600c900520045/test.odt
But whenever I am trying with apache request os.system(command) it goes in process but doesn't return anything. The process keeps running in background continously.
Have you thought about using
subprocess.call(["ls", "-l"])
"The subprocess module allows you to spawn new processes, connect to their input/output/error pipes, and obtain their return codes. This module intends to replace several older modules and functions:"
os.system
os.spawn*
os.popen*
popen2.*
commands.*
Ref Python 2.7.x module subprocess
I'm developing a kernel extension which processes every socket is build on system and waits in user space to get confirmation from user to allow or deny that socket.
I'm using IOSleep to apply the wait i mentioned above but it gives this error when loading kernel extension.
"the following symbols are unresolved for this kext:
_IOSleep"
First of all , i want to know am i correct about using IOSleep to make waiting ?
If not , how should i apply desired waiting to cover time interval that i need to get user confirmation about allowing or rejecting a specific socket connection?
Thanks in advance for any useful response.
IOSleep is perfectly fine in a kernel extension. The error you see is because libraries are linked to kexts at load time, not compile time.
When you add functions to your code that require linking against new libraries, you must call kextlibs on the compiled binary in order to find out what you need to add to the plist file. This is explained in the Add Library Declarations section of the Generic Kernel Extension tutorial in the Mac Developer Library, but it's easy to forget to do this after the first time.
The basic steps are:
Build your kext
Run the command kextlibs -xml MyKext.kext in the Terminal
Replace the <key>OSBundleLibraries</key><dict>...</dict> part of your kext's Info.plist file with the printout from the above
Rebuild your kext
It should now link correctly when you load it with kextload.
On windows and such I used to use a trick to find out of a file is currently in use (written specifically).
I use to open the file for writing and if it failed most likey another process is busy accessing it.
Sadly these trick (using C OPEN with exclusive lock for writing) doesn't work on my Mac. While my curl in a terminal is still writing my -fileBusy() check fails.
fcnt call on the fd with F_GETLK doesn't reveal any locking as well.
Is there any chance for me to detect if a file is in use by another process?
Ps> listening for fsevents can't be done because my app launches after the is created by the other app / process.
Apple confirmed via email that the solution described in the link below is a valid one and not considered a private API.
More information:
http://lists.apple.com/archives/cocoa-dev/2010/May/msg01455.html
You could try running the following shell command using NSTask:
lsof -Fc path/to/thefile
That will give you the process ID and name of any process(es) that have thefile open.