/proc/self/stat not opening when compiled through pgcc

Hello,

I have a simple program:

#include<stdio.h>
void main()
{
FILE *hfile;
hfile=fopen(“/proc/self/stat”,“r”);
if(hfile==NULL)
{
printf(“File not found”);
}
else
{
printf(“File found”);
fclose(hfile);
}
}

When I compile through gcc in generic cygwin and run, I get “File found” whereas when I compile through pgcc in generic cygwin or PGI cygwin environment (shipped with PGI C/C++/Fortran Workstation) I get “File not found”.

Can you please let me know, why is this so ? What is the issue when I compile through pgcc ? How to resolve it ?

Thanks & Regards,
Kunal

Hi Kunal,

PGI is a native Windows compiler not a Cygwin compiler. Cygwin is included with our product for it’s tools as a convenience to our customers. Hence, when using the ‘fopen’ system call is made, you are calling a Windows run time function, not Cygwin, and need to use Window’s PATH names. However, “/proc” is a virtual file system and can’t been by opened by Windows.

  • Mat

Hi Mat,

Thanks for your reply !!
Is there any workaround for that, that you are aware of ?

I was wondering if it works in generic cygwin env. with gcc then there should
be some way to get it working with pgcc in PGI cygwin env.

Thanks & Regards,
Kunal

Is there any workaround for that, that you are aware of ?

Not that I’m aware of.

I was wondering if it works in generic cygwin env. with gcc then there should
be some way to get it working with the PGI cygwin env.

I think this is the main cause for your confusion. There isn’t a “PGI cygwin env”. PGI is native Windows. Windows programs run fine under Cygwin so we ship a standard Cygwin installation with the compilers so users moving from Linux to Windows have some of the tool’s they are used to (like ‘make’) available. User’s can there own Cgywin installation or not use Cygwin at all.

  • Mat