<div dir="ltr"><div>I'm not sure you need waitpid call at all, but if it is needed for some side effects, then try to pass it as:</div><div>waitpid(Me.pid, Null, 1) ''IE WNOHANG</div><br><div><br></div><div>Jussi<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Jun 9, 2018 at 1:57 AM, Jussi Lahtinen <span dir="ltr"><<a href="mailto:jussi.lahtinen@gmail.com" target="_blank">jussi.lahtinen@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>With exec or shell command, but I'm not sure that is what you want to do. I think you want to attach to existing process.</div><div><br></div><div>From the documentation:</div><div><i>"The <b>waitpid</b>() system call suspends execution of the calling process until a child specified by pid argument has changed state."</i></div><div><br></div><div>So this is what you observe as freezing.</div><div></div><div><br></div><div><i>"By default,
<b>waitpid</b>() waits only for terminated children, but this behavior is modifiable via the options argument, as described below."</i></div><div><i><br></i></div><div>Not sure what this means... maybe they meant to write "... waitpid waits only for termination of the children ...".</div><div>Are they required to be child processes or do attaching to process count as child process? I don't know. If so, I don't think the options argument can be zero in your case.</div><span class="m_-2020266993320767296HOEnZb"><font color="#888888"><div><br></div><div><br></div><div>Jussi<br></div><div><i></i></div><div><i></i><br></div></font></span></div><div class="m_-2020266993320767296HOEnZb"><div class="m_-2020266993320767296h5"><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Jun 9, 2018 at 1:22 AM, Demosthenes Koptsis <span dir="ltr"><<a href="mailto:demosthenesk@gmail.com" target="_blank">demosthenesk@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span>On 06/09/2018 12:11 AM, Tobias Boege wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Fri, 08 Jun 2018, Demosthenes Koptsis wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello, i implemented a ptrace and waitpid external functions in order to<br>
read/write a memory address of a process.<br>
<br>
i want to make a trainer for a game in gambas and i created a small program<br>
that reads and writes to a memory process.<br>
<br>
The problem is that when i try to write to memory it freezes at waitpid<br>
line.<br>
<br>
i attach the test program you have to 1) open it as root 2) run a process<br>
you want to hack and get the pid 3) scan memory with scanmem and locate an<br>
address you want to write. 4) run my test program and see it freezes.<br>
<br>
Any help?<br>
<br>
</blockquote>
Does the same code work in a C program? It seems like waitpid() is just what<br>
you need to do after PTRACE_ATTACH, but anyway I'd say it's a good idea to<br>
develop the low-level bits in C first, so that we're sure it's the translation<br>
to Gambas which is faulty, and not the algorithm.<br>
<br>
Three other remarks:<br>
<br>
* I'm certainly not running a random somebody's buggy program as root.<br>
Can't you spawn a child process yourself and then use PTRACE_TRACEME<br>
for debugging purposes? That shouldn't require root privileges.<br>
<br>
* You should also check return values of system calls.<br>
<br>
* THIS MAILING LIST IS DEPRECATED. USE THE NEW ONE: <a href="https://lists.gambas-basic.org/listinfo/user" rel="noreferrer" target="_blank">https://lists.gambas-basic.org<wbr>/listinfo/user</a><br>
<br>
Regards,<br>
Tobi<br>
<br>
</blockquote></span>
i also test it with c++ with codeblocks and it also freezes at waitpid of WriteMemory function<br>
<br>
how i spawn a child process?<div class="m_-2020266993320767296m_5249934600676777554HOEnZb"><div class="m_-2020266993320767296m_5249934600676777554h5"><br>
<br>
----[ Gambas mailing-list is hosted by <a href="https://www.hostsharing.net" rel="noreferrer" target="_blank">https://www.hostsharing.net</a> ]----<br>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div></div>