This is a follow up/modification of my qn : Ptrace/wait on a non child
How do I ptrace or wait on a process that is not a child AND the process that waits is not a root user .
I tried to be in the same group, still doesnt work [ operation not permitted - to ptrace on a non-child ]
ptracing a process gives you complete control over it. If you could ptrace a process belonging to a different user, then users would be meaningless.
wait is specifically for parent notification.
You'll have to rethink your approach to whatever problem you're trying to solve.
Related
Is it possible to run a child process as a parent process?
My directory structure looks like this:
app/program.exe
app/bin/internal.exe
app/bin/something.dll
The program.exe just executes the internal.exe with some arguments.
#include <stdio.h>
#include <process.h>
int main(void) {
_execl(".\\bin\\internal.exe",
"internal.exe", "some args", NULL);
return 0;
}
The arguments are important; without them internal.exe won't do anything.
This mostly works alright, but doesn't integrate well with the taskbar. The program shows up in the taskbar as internal.exe, and pinning it to the taskbar isn't useful, because clicking on the pinned shortcut will execute internal.exe without the arguments, and it will close immediately.
I'd like it to show up as program.exe on the taskbar, so that pinning it to the taskbar pins the working "launcher" instead of the internal part.
Is this possible?
You can't change the child to become the parent in terms of actual processes. The taskbar works at a higher level and gives you more control.
MSDN says:
The following items describe common scenarios that require an explicit AppUserModelID. They also point out cases where multiple explicit AppUserModelIDs should be used.
...
Cooperative or chained processes that to the user are part of the same application should have the same AppUserModelID applied to each process. Examples include games with a launcher process (chained) and Microsoft Windows Media Player, which has a first-run/setup experience running in one process and the main application running in another process (cooperative).
If you are not the author of the child application things become complicated.
If it is Java or some other type of framework it should have the IsHostApp value set. If not, you can try playing with UseExecutableForTaskbarGroupIcon and TaskbarGroupIcon but these will not change the AppUserModelID. Setting NoStartPage will prevent the user from pinning the child application.
If you know how to find the window of the child application you can call SHGetPropertyStoreForWindow in the parent and set the id to the same id as your parent process and/or set the System.AppUserModel.Relaunch* properties.
Firstly, I don't need a code. I can write codes too! I need your advices and ideas. I have two C files one is server, the other one is client-maker. The server has 4 children(employees of server) to respond incoming requests from children(clients) of the client-maker, that is, client-maker forks number of 3, 6, .. children subject to argument specifying client(children) number to be forked. There is a well-known FIFO which is known by server ,as well as all children, to receive requests from clients(forked children by client-maker).
The server(employer of the 4 children) forwards the requests orderly to the idle children. Each of the children does equally similar jobs. The child done its job must tell its parent(server) that I'm ready to get a new job(answer to client).
My problems are as follows,
How does the server forward the incoming requests to the idle
children(the 4 children of server)? What is the way/method that I need to use?
How can I know the child is idle at that time?
How can the child tell its parent(server) that I'm ready to get a
new job(answer to client)? By what way/method?
I can't start writing my program since I can't answer the questions. I mean - since I can't build its structure. -
Please, propose solutions only with FIFO or PIPE IPCs and signals.
Maybe I can use a counter which is adjusted by the 4 children by guarding with a semaphore. But I'm not sure.
I am developing a system where a single parent process creates 10 child processes. The parent process assigns independent tasks to individual child and parent-child communication is done via message queues. Now I need to add one more functionality by which asynchronous timers would run and at a regular interval, timer asks the parent process to ping each child process to check if child is running fine and child replies back. If a child does not reply back thrice after the ping call is made, the parent kills the child and forks another child to assign that task. What would be the best option to add this timer which would trigger IPC between parent and child processes at a regular interval? I was trying to build individual process wise timer with timer_create but could not achieve it.
I'm trying to figure out how to set up an event that could be carried into a child process. I need this in order to calculate the time it took for the parent process to communicate with the child process. The code I've got is here: http://pastebin.com/euVfSNeg
The problem is that when the app2.exe calls app3.exe nothing happens, because the event doesn't get fired/listened (dont know which one is the case).
I need to figure this out ASAP as I've got to hand it in in a couple of hours.
Any help would be appreciated.
The MSDN page says:
lpEventAttributes A pointer to a SECURITY_ATTRIBUTES structure. If
this parameter is NULL, the handle cannot be inherited by child
processes.
A child process created by the CreateProcess function can inherit a
handle to an event object if the lpEventAttributes parameter of
CreateEvent enabled inheritance
And you're passing NULL as the first argument.
I have a Windows service (under WinXP SP2), running under the LocalSystem account, that launches processes using CreateProcessWithLogonW. In order to clean up child processes, I'm trying to use a job object and TerminateJobObject.
MSDN states that the job handle must have JOB_OBJECT_ASSIGN_PROCESS access right, which it has since it's created via CreateJobObject. The process handle must have PROCESS_SET_QUOTA and PROCESS_TERMINATE rights. I think it has them since TerminateProcess and SetProcessWorkingSetSize both return with no error.
Though, AssignProcessToJobObject fails with errno 5 (Access denied). Everything works fine if I replace CreateProcessWithLogonW with a simple CreateProcess.
Am I missing something or is what I'm trying to do impossible ?
Edit: It seems that svchost.exe, which actually creates the process when CreateProcessWithLogonW is used, already assigns the process to an anonymous job. The CREATE_CREAKAWAY_FROM_JOB flag is ignored by this function. So the real question is: is there a way to prevent svnhost from assigning the process to a job ?
From Jeff Lawson on MSDN:
Interactions with Win32 Job Objects
CreateProcessWithLogonW executes the
new process as a child of the
Secondary Logon service, which has the
outcome of making the process escape
any Job Object membership/restrictions
even if the Job Object did not allow
breakaway.
Furthermore, the Secondary
Logon service automatically creates
its own new Job Object and assigns the
new process into it. As such, it is
not possible for the caller to
explicitly assign the new process to
any other Job Object (since a process
may only be assigned to one Job
Object, and can never be removed from
a Job Object once it has been assigned
to one).
Does each new process need a different logon? Otherwise, you could create a single process with the new logon and have it spawn new process using CreateProcess that could then be associated with a Job Object.
we can enable privilege and use CreateProcessAsUserW instead