Programming :: Get List Of Thread In Running Process?
Jan 27, 2010How to get list of threads of a process using C code in Linux?
View 6 RepliesHow to get list of threads of a process using C code in Linux?
View 6 RepliesIn short our required is that we are creating a share library which can be loaded by a process and that share library analysis the process which load it. Since share library is in address space of the process so I need to find out how many threads created by the process and what is status of their stack trace etc.
So I am looking for a way to get list of threads in running process.
I want to know, is there any way to prevent the multi-thread process from crashing if some errors (say, segmentation faults) occur in one of its child threads? I've found pthread_sigmask() function, but that does not seem to work:
Code:
#include <stdio.h>
#include <unistd.h>
[code]...
This is a client server issue where the server creates a new thread for listening to a new client, now when the thread starts execution and during its execution the server needs to pass it an object of some X class, how's that to be done?
View 4 Replies View RelatedI am going to use "pthread_setaffinity_np" to bind a thread to a specific core. My application has two threads. I have used mutex to assign a specific id to each thread and then bind that thread to a core different from another core. but it seems that the os assigns both thread to one core.What should I do to bind each thread to a specific core?
View 4 Replies View RelatedHow do you list processes, get a process's std(in|out|err) stream, or wait until a process is finished in C?
View 3 Replies View RelatedIn the comments section of this blog, the commenter "Pratik" claims that you can edit a running bash script, without killing it, and have the changes picked up by the running script. He claims you can do this by editing files in /proc. Now, I know how to find the /proc folder that contains the data on the running process, Code: cd /proc/`pgrep process_name` But I can't figure out what I should do if I want to edit a running bash script.
View 6 Replies View RelatedI have a requirement where I want to extract the full name of the process running in my box. I tired various options of ps. The wide option gave me the full command but that contains command, the interpreter and also the arguments passed.
Code:
XX XX XX XX XX XX /usr/bin/sh /path/to/exe/myexe.sh arg1 arg2 arg3.
Is there any way from ps or any other command I can extract the full name of the command
Desired Output :
Code:
/path/to/exe/myexe.sh or myexe.sh
is there a way for me to grep the process that running more than 30 days only using linux command or script?
example:i do ps -ef to list out the process, then i want to filter only the process that always running more than 30 days..
I need a help regarding ,how to shutdown the running process using C program?..here i attached the porgram to shutdown the system by c program is there any possible to change in this program to shutdown the process?
View 1 Replies View RelatedI have p1,p2,p3,p4 some processes created by me in C. p1, p2, p3 are started individually from several consoles. And I want process p4 to terminates processes p1, p2, p3 if they are running. Which is the easiest way to accomplish that? put all processes in the same process group and send from p4 a kill signal to the group. But I couldn't do that because I cannot call successfully setpgid(getpid(), 15000) from p1-p4. It's there some way to put them in the same group? the processes don't have a child-parent relationship, they are launched manually from consoles.
View 1 Replies View RelatedI am working in HP UNIX. I have one process which is running continuously.There is log file generated for the process. I want to take back up of file without loosing any logs after particular interval of time or say file size increases more that 1GB.
View 3 Replies View Relatedthese are the functions I am using for creating threads..
#include "mythread.h"
/** Global Data **/
tcbList_t *readyList = NULL; /* Ready list */
tcb_t *runningTCB; /* Currently running thread */
tcb_t mainTCB; /* Starting threads's TCB */
[code]....
The function endThread() currently simply ends the entire program, not just the terminating thread. I need to modify the function endThread() so that it will place the terminating thread on the zombie list and switch to the next ready thread if the ready list is not empty. If the ready list is empty then endThread() should switch back to the main thread (the state of the main thread was saved in "mainTCB" by initiate())... and, in createThread() space is malloc'd for the thread's TCB and stack. This space should be freed...
I am trying to get a list of running processes using audio (using gstreamer), just like in gnome-volume-control, under applications, but have so far been unsuccessful in finding anything in either the gtk or gstreamer library, anyone out there who can point me in the right direction?
View 1 Replies View Relatedis there any tool can show the thread/process schedule information? i would like to know when the thread/process wakeup, and when it was suspend? it includes kernel and user space. With this information, i can know the thread/process task schedule, and calculate the MIPs.Another, do you know whether LTT support User space thread trace?
View 2 Replies View RelatedIt's called TextRipper and it creates indexable and editable text files from any image. Feel free to copy TextRipper; it's licenced under GPL. My troubles are with cracking passworded pdf's. (As you can see, I meant any when I said any image.)
I can't find a way for the user to cancel the decryption process by exiting the script without pdfcrack orphaning. Line 349 works the rest of the time; the concerned process is line 228. I believe it's a piping/subshell problem. At least that's how I've been going at it in vain.
I've made portability a priority and that the comments still require updating.
Code:
If the result is one output file, TextRipper will open it for you in OpenOffice Writer.
Otherwise all txt output files (editable and indexable) will be in the original file's directory." 0 0
I have an ubuntu 10.10 server and want to run a script on it to check if a process is running. If it is not running, it will start the process and also write into a log file.
When running the script i get the following error message:
syntax error near unexpected token `else'
Here is my script.
How to stop a thread by using commands? Other threads in that process shouldn't disturbed. Is it possible to do the same?
View 2 Replies View RelatedA simple TCP based chat server could allow users to use any TCP client (telnet, for example) to communicate with each other. For this question you should consider a single process, single thread server that can support exactly 2 clients at once, the server simply forwards whatever is sent from one client to the other (in both directions). Your server must not insist on any specific ordering of messages as soon as something is sent from one client it is immediately forwarded to the other client. As soon as either client terminates the connection the server can exit
View 4 Replies View RelatedI installed mysqld with yum then yum quit working with this error:http://yum.baseurl.org/ticket/70 when mysqld is stopped yum works again. what does a running instance of mysqld have in common with a python yum package manager?
rpm -qa rpm* python* yum* mysql* | sort
mysql-5.0.45-7.el5
mysql-devel-5.0.45-7.el5
mysql-server-5.0.45-7.el5
[Code]...
Assume someone bind a particular process to a particular CPU core(In multi core machine) by using sched_setaffinity() like functions. Then how we can get that process running core id and CPU core utilisation of that process on that running CPU core(Pragmatically or by a Linux command)?.
View 5 Replies View RelatedI am troubleshooting something and I got this problem.
If I do "pstree -p"
It shows,
Code:
[code]....
However, it does NOT show up in "ps -elf"
Code:
ps -elf | grep soffi
0 S whho 7734 1 0 80 0 - 36435 - 11:14 pts/2 00:00:03 /usr/lib/openoffice/program/soffice.bin -splash-pipe=5
0 S whho 7833 7759 0 80 0 - 751 - 11:21 pts/3 00:00:00 grep soffi
I was wondering if 7735, 7736, 7737, 7743 were really processes. Then I checked /proc, I could cd to /proc/7735, /proc/7736, etc, but I could not ls them out. I looked at the man page of "pstree", it says,
Code:
Child threads of a process are found under the parent process and are shown with the process name in curly braces, e.g.
icecast2---13*[{icecast2}]
So, what does all this mean? Does it mean that 7735, 7736, 7737, 7743 are just threads but not processes? If so, why could I cd to /proc/<id> but not see them in "ps -elf".
What is the quickest way to get the thread id(tid) of the current thread in linux? Specifically I use fedora 13. ...and I am talking about inside a C++ program.
View 2 Replies View RelatedIs there a library/system call that will return to me what CPU core a thread of execution is running on? I've looked for a bit on the net already and also in /usr/include and couldn't find one.
getcpu() and sched_getcpu() are two that I found, but when I include the appropriate header files (linux/getcpu.h, and sys/sched.h respectively), gcc says getcpu.h doesn't exist and the linker complains it cannot find the implementation in sched.h.
I'm sure I'm doing something really stupid or overthinking...
What I am doing is running an OpenMP application and specifying a list of cpu cores to run on with GOMP_CPU_AFFINITY. I want to make sure that each core is getting the same number of threads.
**UPDATE**
It seems that this code works, but only with glibc >= 2.6, and my machine has 2.5:
Code:
#define _GNU_SOURCE
#include <stdio.h>
#include <utmpx.h>
int main( void )
[Code].....
Sometimes I connect to my Debian box from another computer (using SSH on Cygwin or Linux), and once ina while I want to run some console apps. And sometimes some of these apps might complain about "another intance, Error: an instance of newsbeuter is already running (PID: 2496)". Is there a work around for this issue at all(without killing the original instance") ? The reason I do not want to kill the app because there might be 2 users connected to the same machine that might be using the same app.
View 1 Replies View RelatedI have a program which is uses sigaction to register for a SIGIO signal (for incoming data on a fd) with an appropriate event handler. I also create a new detached thread 'B' that does some work with the received data. Normally the thread B runs properly. But when my event handler is called (because a there is new incoming data), after the event is handled, the thread B is not called immediately. There is a noticeable delay of the order of many seconds before it is scheduled again .During this delay, my program is doing nothing.
What am i doing wrong? Is there someway i can run thread B as soon as the event is handled (and assuming no other work is to be carried out)?
i created one thread in main(). I have while in thread function.
I want close the thread in main after some time. How can i close it.
Kernel: 2.6.24.2
System: Embedded System
I have a process and two threads running in it. Thread1 is my GUI-Thread (using FLTK) and Thread2 is running at the first 10 sec. after start.Now, I would like to make Thread2 "nicer" to Thread1, because otherwise GUI stucks sometimes. But I didn't find a solution.Is it possible to define the "niceness" of threads inside a process (to each other)? And if so, how do I have to do this?
I have to launch a new thread from my existing main program and pass data to it.
For now the data is simply a string value.
How I go about passing data to a new thread while it is running.
When I set the stack base address of the child thread using the POSIX library function "pthread_attr_setstackaddr()", I am unable to access the memory contents of its parent. The data-structures that are created on the HEAP of its parent using malloc() are either getting destroyed or unaccessible when moving to the context of the child thread. These data-structures are being passed as an argument to the child thread.Even if I make these variables global then also it is not working.pthread_attr_setstacksize(tattr, ...);stackbase = (void *) malloc(...);pthread_attr_setstackaddr(tattr, stackbase);But when I create the child thread without setting its stack base address using that pthread_attr_setstackaddr(), then it is able to access the parent's memory contents.
View 1 Replies View Related