Operating System - HP-UX
1832947 Members
2906 Online
110048 Solutions
New Discussion

"open failed: No such file or directory"

 
Hariprasad
New Member

"open failed: No such file or directory"

main(){
char buf[1024];
int fd, count;
if ((fd = open("/dev/ttya", O_RDWR)) < 0) {
perror("open failed");
exit(1);
}
when i try to run the above code i am getting the following error
"open failed: No such file or directory"
can i anybody help why open system call has failed
3 REPLIES 3
A. Clay Stephenson
Acclaimed Contributor

Re: "open failed: No such file or directory"

The most obvious answer is that /dev/ttya does not exist.
I really prefer to capture errno myself after a system call failure and display that value. It is also possible that ttya exists but has very screwy major/minor device numbers. Do an ls -l /dev/ttya and post that and we can probably get closer to the problem.
If it ain't broke, I can fix that.
A. Clay Stephenson
Acclaimed Contributor

Re: "open failed: No such file or directory"

The most obvious answer is that /dev/ttya does not exist.
I really prefer to capture errno myself after a system call failure and display that value. It is also possible that ttya exists but has very screwy major/minor device numbers. Do an ls -l /dev/ttya and post that and we can probably get closer to the problem.
If it ain't broke, I can fix that.
Bill Douglass
Esteemed Contributor

Re: "open failed: No such file or directory"

Or perhaps do:

ls /dev/tty*

and see what tty devices are actually defined on your system.