w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
how to dump the call stack information for native(C/C++) process explicitly when it is not crashed in linux
Throw an exception and catch it immediately. I'm not familiar enough with C but in java this would look like this: try { throw new RuntimeException("bla bla"); } catch (Exception ex) { ex.printStackTrace(); }

Categories : Android

How many open files for each process running for a specific user in Linux
This command will tell you how many files Apache has opened: ps -A x |grep apache | awk '{print $1}' | xargs -I '{}' ls /proc/{}/fd | wc -l You may have to run it as root in order to access the process fd directory. This sounds like you've got a web application which isn't closing its file descriptors. I would focus my efforts on that area.

Categories : Linux

Tomcat process killed by Linux kernel after running out of swap space; don't get any JVM OutOfMemory error
You probably have other processes on the same computer that also use memory. It looks like your java process reaches around 5.3GB before the machine is desperately out of RAM and swap. (Other processes are then probably using 12GB-5.3GB = 6.7GB) So your linux kernel sacrifices your java process to keep other processes running. The java memory limit is never reached so you're not getting an OutOfMemoryException. Consider all the processes you need running on the entire machine, and adjust your Xmx setting accordingly (enough to leave room for all the other processes). Perhaps 5gb? In any case, counting of OutOfMemoryExceptions being delivered is a pretty bad code smell. If I recall correctly, getting even a single OutOfMemoryException can leave the JVM in an "all-bets-are-off" state and

Categories : Java

Linux ps command - get process running time - different between etime and time parameter
Use the linux command time. It record three kind of process running time. real: wall time. user: user space time. sys: kernel space time. Find this link: Linux time command

Categories : Linux

How to issue a command from the command line of a process running on Linux
If you don't mind waiting for the calls to finish (one at a time) before returning control to your program, you can use the subprocess library. If you want to start something running and not wait for it to finish, you can use the multiprocessing library.

Categories : Python

In Java What is the exit value of a process which is killed in the background through Linux shell using process id
This is not a Java specific question. The return code will be the same for all Unix systems here (at least I have never seen a Unix system not behaving this way): 128 + the number of the signal which caused the process to terminate. No idea for Windows... Therefore, 130 in your case. In C, you'd check (after a call to waitpid() for instance) whether a process has been terminated by a signal using WIFSIGNALED(status).

Categories : Java

Getting the list of child process, called by a parent process in Linux
The f option of the ps command will help. Try: ps afx This will show all processes and will visualize parent -> child dependencies in the console.

Categories : Linux

How to get the Parent Process ID by giving a Process ID in Linux using C/C++?
I think you can use get_proc_stats function to do this. But you need to install the libproc-dev library. Here is an example : proc_t p_info; get_proc_stats(pid_num, &p_info); int parent_pid = p_info.ppid;

Categories : C++

How to trigger an automatic screen lock process on my android phone after a specified process running specified time?
How unlock and lock screen programatically in android Has some excellent information on immediately calling the lock screen. You could implement a system using an alarm manager to trigger this event.

Categories : Android

Is a multi process Java program a single process in the context of the actual machine underneath the JVM it is running on?
You're confused between processes and processors. A JVM counts as a single process on your machine, yes. When you start the JVM it runs as a program and it executes Java byte code. A JVM can address all the processors on you machine. When you start a Thread in Java it executes on an available processor.

Categories : Java

Check if a process started with Process.Start is still running?
I found a way to check if one process has the file in his "CommandLine", meaning that it is currently editing the application: private static void OpenProcessIfNeeded(String file) { using (ManagementObjectSearcher mos = new ManagementObjectSearcher("SELECT CommandLine FROM Win32_Process")) { foreach (ManagementObject mo in mos.Get()) { if (mo["CommandLine"] != null && mo["CommandLine"].ToString().IndexOf(file, StringComparison.InvariantCultureIgnoreCase) > -1) { Console.WriteLine("Found!: " + mo["CommandLine"]); return; } } } Process.Start(file); }

Categories : C#

Calculate latency for touch screen UI running on ARM controller board running Linux
There are 3 latencies involved in the above scenario 1. Time taken for the touchscreen to register the finger and raise an input-event. Usually a few milliseconds. Enable FTRACE and log the following with timestamps -- ISR -- Entry of Bottom-half -- Invoking of input_report() 2. Time taken by the app responsible for the GUI to update it. Depending upon the app/framework, usually the most significant contributor to latency. Add normal console logs with timestamps in the GUI app's code -- upon receiving the input event -- just before the command to modify the GUI 3. The time taken by the display to update. Usually within 15-30 milliseconds The final latency is a sum-total of the above 3 latencies.

Categories : Linux

How can I lock UI while running the long running process in the main UI Thread in WPF (code in C#)
I would do it this way: Make a "global" (seen for UI thread and background thread) object of one of concurrent types. You can make it as singleton or pass an object to both threads All the long running thread does is reading data from concurrent object and process them. If main thread (or any other) need to do anything in background simply adds it to the concurrent collection. This kind of approach in concurrent programming is called Producer-consumer problem

Categories : C#

Get child process id of already running process
In node.js you can do it via child_process library. There is a pid member function that returns the spawned child's pid. E.g. var spawn = require('child_process').spawn, grep = spawn('grep', ['ssh']); console.log('Spawned child pid: ' + grep.pid); grep.stdin.end(); You can also kill the child process with kill. The pty.js does a fork with a pseudo terminal, which is useful if emulating terminal. Otherwise you should use child_process to spawn/fork new processes.

Categories : C

How to get Process object of already running process?
I believe you want GetProcessesByName. It will return an array of all the processes that match the name you give. array<Process^>^ notepadProcesses = Process::GetProcessesByName("notepad");

Categories : C++

Get Process Information After Termination
Quoting from man 5 proc: /proc/[pid] There is a numerical subdirectory for each running process; the subdirectory is named by the process ID. A terminated process is no longer running, and its /proc/[pid] directory (including the stat file), is no longer going to be there. If it was going to be there, you can just store the PID in a variable before you call proc.wait(): pid = proc.pid proc.wait() with open('/proc/%d/stat' % pid, "r") as f: There is no 'just before termination' event; subprocess waits, then reaps the exit code. You could do your own waiting with os.wait4() instead: pid, status, resources = os.wait4(proc.pid, 0) cpu_time = resources.ru_utime + resources.ru_stime resources is a named tuple, see resource.getrusage() for a list of what names it supports. Both .

Categories : Python

How to get process information using pid with Java?
Well, all of those information you can get from the OS. For example, the task manager in Windows. What Java can offer you is, for example, the thread dump: %JAVA_HOME%/bin/jstack.exe PID >stack.txt Or, the heap dump: %JAVA_HOME%/bin/jmap.exe -dump:format=b,file=heap.bin PID

Categories : Java

Get information on another process on windows from nodejs
I think you are looking for Tasklist. This will give you the pid and memory usage. Try this: var spawn = require('child_process').spawn; ps = spawn('Tasklist'); ps.stdout.on('data', function (data) { console.log(data); }); ps.stderr.on('data', function (data) { console.log('ps stderr: ' + data); }); I'm not sure if tasklist can do cpu usage. However, you can download and install ProcDump, then do something similar to the code above. var spawn = require('child_process').spawn; ps = spawn('procdump -ma ' + somePid); // or 'procdump iexplorer' ps.stdout.on('data', function (data) { console.log(data); }); ps.stderr.on('data', function (data) { console.log('ps stderr: ' + data); });

Categories : Windows

How to get process information from windowHandle in Native with Java?
Considering use Java Native Access. Download jna.jar and platform.jar from here. You may have noticed that we can use GetWindowThreadProcessId in user32.dll to get the pid from a window handle. Then we can use OpenProcess in kernel32.dll to get a pointer to that process. Then the bunch of APIs like GetProcessMemoryInfo and GetModuleBaseName in psapi.dll can help you to get process information from that process object and the GetProcessTimes in kernel32.dll can return cpu usage. The GetProcessMemoryInfo contains a structure named PROCESS_MEMORY_COUNTERS which needs Structure in JNA to handle. static class Kernel32 { static { Native.register("kernel32"); } public static int PROCESS_QUERY_INFORMATION = 0x0400; public static int PROCESS_VM_READ = 0x0010; public static nati

Categories : Java

Process information using Python, NOT using wmi, psutil, tasklist
The technique to retrieve a process's command line is somewhat hacky but was included into WMI since XP. Basically, it's reading another process's memory. See e.g. Getting another process command line in Windows and links from there for details. So, you either re-implement it yourself by hand, with ctypes or whatever, like the link above says, or somehow, utilize existing modules that will do that for you. There's zipimport to make this easier for multiple files and virtualenv to create whole environments anywhere on the filesystem, the latter likely being an overkill.

Categories : Python

Get current process identity and authentication information
It would be easiest if you could leverage the built-in authentication of IIS or WCF. If you really need a TCP socket, I think you have to implement the authentication yourself. It's not conceptually difficult if you understand how Kerberos works, but it will take a while to work out the details of all the functions to call. MSDN has a decent overview here. In addition, I'm not aware of any C# wrappers for these, so you would probably need to p-invoke them all; consider writing that part in managed C++.

Categories : C#

extract information from text file in linux
grep -o "[0-9].[0-9]+" will get all numbers with decimal points (which should get you your 4.00 if your format stays the same) grep -o "build[0-9]+" | sed "s/[^0-9]+//" should get you whatever number comes after build in the first line grep -o "".+"" | sed 's/"//g' should get you any single-line strings that are surrounded in quotes, which seems to give you your hostname. Unless there might be quotes in other formats of the file.

Categories : Linux

How to retrieve the register information of the specified thread in Linux?
The ptrace system call is the standard debugging facility in Linux, which GDB uses to interact with other processes being debugged. GDB probably gets this information with the PTRACE_GETREGS or PTRACE_GETREGSET requests. ptrace man page

Categories : C

using QT process to get sensor information from the laptop using command line
process->start("sensors | grep "Core""); The problem here is that the start function takes the first parameter as the program to execute and then passes subsequent parameters to the program as arguments, so the | grep and "Core" are being passed to the sensors command, which is then complaining because it doesn't know what to do with those arguments. One way to solve this is to call sensors and get the returned information with readAllStandardOutput(). You can then either use the Qt string functions to search for the information you want, or if you set the standard output file with setStandardOutputFile, you can then call QProcess with grep on the that file. (Note QTemporaryFile may be of use here). However, the simplest way would be to create a small command line script that calls

Categories : C++

Information regarding Internal signal handler table in Linux?
In Linux signal handlers are stored per task in objects of type struct sighand_struct struct sighand_struct { atomic_t count; struct k_sigaction action[_NSIG]; spinlock_t siglock; }; This object is referenced from struct task_struct through sighand field. Instead of gdb (which is a tool for user space), use crash. Reading from task_struct: crash> p/x *((struct task_struct*)0xdfcb04c0).sighand $9 = { count = { counter = 0x4 }, action = {{ sa = { sa_handler = 0x0, sa_flags = 0x0, sa_restorer = 0x0, sa_mask = { sig = {0x0, 0x0} } } }, { sa = { sa_handler = 0x0, sa_flags = 0x0, sa_restorer = 0x0, sa_mask = { sig = {0x0, 0x0}

Categories : Linux

Fixing 'no symbolic type information' from dtrace in Linux?
Well, after a trip to gdb, I figured that the problem occurs in dtrace's function dt_module_getctf (called via dtrace_symbol_type and, I think, dt_module_lookup_by_name). In it, I noticed that most calls propagate the attribute/variable dm_name = "linux"; but when the failure occurs, I'd get dm_name = "kernel"! Note that original line 60 from sched.d is: cpu_id = `dtrace_cpu_id; /* C->cpu_id; */ Then I found thr3ads.net - dtrace discuss - accessing symbols without type info [Nov 2006]; where this error message is mentioned: dtrace: invalid probe specifier fbt::calcloadavg:entry { printf("CMS_USER: %d, CMS_SYSTEM: %d, cpu_waitrq: %d ", `cpu0.cpu_acct[0], `cpu0.cpu_acct[1], `cpu0.cpu_waitrq);}: in action list: no symbolic type information is available for unix`cpu0: N

Categories : Linux

View/extract file signature information in linux
what kind of fine are you try to see the signature of ? Try to look at this page if its an exe: http://hype-free.blogspot.dk/2008/09/how-to-verify-executable-digital.html

Categories : Linux

Linux Process Scheduler
From the man page of sched_setscheduler(), For processes scheduled under the SCHED_FIFO policy, the following rules apply : A SCHED_FIFO process that has been preempted by another process of higher priority will stay at the head of the list for its priority and will resume execution as soon as all processes of higher priority are blocked again. When a SCHED_FIFO process becomes runnable, it will be inserted at the end of the list for its priority. A call to sched_setscheduler() or sched_setparam() will put the SCHED_FIFO process identified by pid at the start of the list if it was runnable. As a consequence, it may preempt the currently running process if it has the same priority. (POSIX.1-2001 specifies that the process should go to the end of the list.) A process ca

Categories : C

Popen new process group on linux
bash does not handle signals while waiting for your foreground child process to complete. This is why sending it SIGINT does not do anything. This behaviour has nothing to do with process groups. There are a couple of options to let your child process receive your SIGINT: When spawning a new process with Shell=True try prepending exec to the front of your command line, so that bash gets replaced with your child process. When spawning a new process with Shell=True append the command line with & wait %-. This will cause bash to react to signals while waiting for your child process to complete. But it won't forward the signal to your child process. Use Shell=False and specify full paths to your child executables.

Categories : Python

How to get files modified by certain process in Linux
If the process is not already running, you can use strace to print system calls strace -o logfile <program> After this, write a script which will look for open() and write() system calls, and able to print the lists of files which are written too. If the process is already running, you will have to use the combination of several things lsof -p or /proc/<processid>/fd/* last modified time stamp of the files found in above output of strace -p <processid> to look for write() and open() Hope that helps

Categories : Linux

cross-process locking in linux
You can use file locking facilities that Linux provides. You haven't specified the language, however you might find this capability pretty much everywhere in some form or another. Here is a simple idea how to do that in a C program. When the program starts you can take an exclusive non-blocking lock on the whole file using fcntl system call. When another instance of the applications is attempted to be started, it will get an error trying to lock the file, which will mean the application is already running. Here is a small example how to take the full file lock using fcntl (this function provides facilities for putting byte range locks, but when length is 0, the full file is locked). struct flock lock_struct; memset(&lock_struct, 0, sizeof(lock_struct)); lock_struct.l_type

Categories : Linux

Setting CPU affinity to a process - C - Linux
OK. This is the stupidest thing that one can ever do! CPU_SET(pid, &mask); CPU_SET(coreid, &mask); changing the pid to the coreid will do it. The other mistake was here: result = sched_setaffinity(pid, sizeof(mask), &mask);

Categories : C

Linux Threads and process - CPU affinity
when process goes in to sleep and when it wake up ,it is not necessary that it will schedule on same cpu.if u have multiprocessor environment then according to scheduler policy it will schedule on any cpu.When process goes to sleep there are different reason ,it goes to sleep beacause it is waiting for io,any resource.When event will occurs it goes from waiting state to ready state.At that time which cpu will be free scheduler will schedule that process on free cpu.It is not necessary it will schedule on same cpu. for extra information about scheduler open source code of scheduler in linux release tree path.

Categories : Linux

Linux zombie process Xsession
Here... I've been using a modified version of this for a while. http://www.mariusv.com/automatic-zombie-processes-killing-shell-script/ Cron it to run every x minutes.

Categories : Linux

Terminate all child process in LInux
You could use process groups setpgid(2) and sessions setsid(2), but I don't qualify what you do as a sandbox (in particular because if one of the processes is setuid or change its process group or session itself, you'll lose it; read execve(2) carefully and several times!). Notice that kill(2) with a negative pid kills an entire process group. Read a good book like Advanced Linux Programming. Consider also using chroot(2). And explain what and why you really want to do. sandboxing is harder that what you think. See also capabilities(7), credentials(7) and SElinux.

Categories : Linux

Linux kill my process for out of memory, how to see how much I use?
First you need to identify what system process is killed by OS. Then I'd enable .core dumping and analyse it. Please check for ulimit -c command and appropriate configuration to get this. Of course you need to enable debug symbols for your program to get most of it. In case you cannot dump (have no sufficient space or any other limitation), consider remote debug with debug version of process on client side. I think you should be able to use something like 'remote GDB debugging' for this. Most probably your process fails on some memory allocation and this has great chance to explain where you 'eat' memory, who is guilty and probably what to do with this. Hope this will help.

Categories : Javascript

How to really free hugepages in Linux for use by a new process?
You can very likely get Java to re use the objects still in memory, However, running the following will remove that and everything else also stored and not being used echo 3 | sudo tee /proc/sys/vm/drop_caches But you dont really need to - although its "taken" its not really. As soon as anything actually needs the ram linux will give it back for more info check out http://www.linuxatemyram.com/ You dont actually need to do anything its normal. The only memory you have to worry about really is the memory when your application is running

Categories : Java

using fwrite as an atomic process on Linux
First write the file to a temporary path on the same filesystem, like /etc/routing_table.tmp. Then just rename the copy on top of original file. Renames are guaranteed atomic. So, the sequence of calls would be, fopen, fwrite, fclose, rename.

Categories : C

When finished create user using (CreateUserWizard control) add profile information in the same process
After creating the User, You need to fetch the profile of recently created user to start updating values. Since No profile is Loaded, it won't allow to set these values for anonymous users. string strUsername = (sender as CreateUserWizard).UserName; ProfileCommon p = Profile.GetProfile(strUsername); //update the field and save p.AdminAddress= txtAdminAddress.Text; p.Save(); The ProfileBase object (provided by the Page.Profile property) includes a useful GetProfile() function that retrieves, by user name, the profile information for a specific user. GetProfile() returns a ProfileCommon object. [ Note: The profile properties set in Config file doesn't allow setting values for Anonymous users. If you want to allow this for anonymous users also use: <add name="AdminAddress" type="Sy

Categories : Asp Net

How do I have a page display new information in Sinatra after a server-side process ends?
In order to use AJAX you have to create an endpoint on your server and use a jQuery or another framework to ease the use of calling the endpoint from javascript. I will paste a short example. The server could look like this: require 'sinatra' set :views, "." get '/' do erb :home end get '/ajax_endpoint' do t1 = Thread.new { sleep 10 } 'Done' #do the job end Put in the views folder (in my case the same as the one the main sinatra app is in) a file with the following content: <html> <script src='http://code.jquery.com/jquery-2.0.3.min.js'></script> <script> window.onload = function() { $.get('/ajax_endpoint', function(data) {$("#the_div").text("Job done!")}) } </script> <body> <div id='the_div'> Loa

Categories : Ruby



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.