Hi,
I actually tried the following code:
////////////////////////////////////////////////////////////////
#include <stdio.h>
#include <unistd.h>
int main()
{
pid_t pid = getpid();
FILE *fi = fopen("/proc/self/stat", "r");
if(fi)
{
printf("Able to open file\n");
}
else
{
printf("Unable to open file\n");
}
//system("ps aux");
printf("PID: %llu\n", pid);
return 0;
}
////////////////////////////////////////////////////////////////
I get the following print on the bash console for MinGW 64-bit:
Unable to open file
PID: 15072
It seems in the MinGW context the UNIX layer emulation is disabled.
Just wanted to know if there is an API something similar to:
"cygwin_winpid_to_pid" to fetch the PID reflected by the ps command for MinGW?
If there is one how to link to it?
On Thu, Nov 12, 2020 at 1:41 PM Cyrille Lefevre via Msys2-users
<[email protected]> wrote:
>
> Hi,
>
> try using /proc/self/stat, see details from
> https://man7.org/linux/man-pages/man5/proc.5.html
> windows pid is got from /proc/self/winpid
>
> Regards,
> Cyrille Lefevre
>
>
>
> _______________________________________________
> Msys2-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/msys2-users
--
Regards,
Ameya Vikram Singh
_______________________________________________
Msys2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/msys2-users