11-15-2007
Where you have O_CREAT:
from the open man page:
Quote:
Exactly one of the O_RDONLY, O_WRONLY, or O_RDWR flags must be used in
composing the value of oflag. If none or more than one is used, the
behavior is undefined.
You are seeing undefined behavior.
10 More Discussions You Might Find Interesting
1. Programming
What is the difference between int** func() and int*& func(). Can you please explain it with suitable example.
Thanks,
Devesh. (1 Reply)
Discussion started by: devesh
1 Replies
2. Red Hat
Hello everey one,
here i am attempting to compile a c++ project .it's throughing the following errors.
my machine details are as follows:
Linux chmclozr0119 2.6.18-53.el5 #1 SMP Wed Oct 10 16:34:19 EDT 2007 x86_64 x86_64 x86_64 GNU/Linux
errors:
=====
Generating... (0 Replies)
Discussion started by: mannam srinivas
0 Replies
3. Programming
Hello,
After, I stat() a file, how can I read the various permissions flags from the st_mode variable which is of type mode_t? I would like to do something like:
struct stat *perms;
int res = stat(filename, perms);
if(perms->st.mode == S_IROTH) do something;
but I know that is the wrong... (2 Replies)
Discussion started by: pallak7
2 Replies
4. Programming
hello everybody!
i have aproblem! i dont know how to concatenate const char* with char
const char *buffer;
char *b;
sprintf(b,"result.txt");
strcat(buffer,b);
thanx in advance (4 Replies)
Discussion started by: nicos
4 Replies
5. Programming
Hi,
I wrote a simple code in C++ converting from UpperToLower case characters. However, my compiler gives me a warning:
"warning: conversion to 'char' from 'int' may alter its value".
Any tips?
I would like to stress, I don't want to load my string into char array.
int ToLower(string... (4 Replies)
Discussion started by: kajolo
4 Replies
6. Programming
Hi,
from the manual
listen(2): listen for connections on socket - Linux man page
It has a parameter called backlog and it limits the maximum length of queue of pending list.
If I set backlog to 128, is it means no more than 128 packets can be handled by server?
If I have three... (3 Replies)
Discussion started by: sehang
3 Replies
7. Programming
Hi,
Can any one tell me why my following program is crashing?
#include <iostream>
using namespace std;
class CA {
public:
const static int i;
};
const int CA::i = 10;
int main() {
int* pi = const_cast<int*>(&CA::i);
*pi = 9;
cout << CA::i << endl;
} (6 Replies)
Discussion started by: royalibrahim
6 Replies
8. Programming
Compiling xpp (The X Printing Panel) on SL6 (RHEL6 essentially):
xpp.cxx: In constructor ‘printFiles::printFiles(int, char**, int&)’:
xpp.cxx:200: error: invalid conversion from ‘const char*’ to ‘char*’
The same error with all c++ constructors - gcc 4.4.4.
If anyone can throw any light on... (8 Replies)
Discussion started by: GSO
8 Replies
9. Programming
My question is simple: When should I use a long, int, char, unsigned/signed variables??
When I declare a variable "unsigned;" what did I do it???
Why would I delcare an integer "long" or "short" ( unsigned or signed)??
Any examples of when things like "unsigned", "long", "short" etc...... (6 Replies)
Discussion started by: cpp_beginner
6 Replies
10. Programming
As this function returns the address of the string corressponding to the errno value provided to it. Can someone please let me know where, in the memory, it could be (on freeBSD).
The MAN page tells under the BUG section that "For unknown error numbers, the strerror() function will return its... (5 Replies)
Discussion started by: Praveen_218
5 Replies
DIO_OPEN(3) 1 DIO_OPEN(3)
dio_open - Opens a file (creating it if necessary) at a lower level than the C library input/ouput stream functions allow.
SYNOPSIS
resource dio_open (string $filename, int $flags, [int $mode])
DESCRIPTION
dio_open(3) opens a file and returns a new file descriptor for it.
PARAMETERS
o $filename
- The pathname of the file to open.
o $flags
- The $flags parameter is a bitwise-ORed value comprising flags from the following list. This value must include one of O_RDONLY,
O_WRONLY, or O_RDWR. Additionally, it may include any combination of the other flags from this list.
o O_RDONLY - opens the file for read access.
o O_WRONLY - opens the file for write access.
o O_RDWR - opens the file for both reading and writing.
o O_CREAT - creates the file, if it doesn't already exist.
o O_EXCL - if both O_CREAT and O_EXCL are set and the file already exists, dio_open(3) will fail.
o O_TRUNC - if the file exists and is opened for write access, the file will be truncated to zero length.
o O_APPEND - write operations write data at the end of the file.
o O_NONBLOCK - sets non blocking mode.
o O_NOCTTY - prevent the OS from assigning the opened file as the process's controlling terminal when opening a TTY device
file.
o $mode
- If $flags contains O_CREAT, $mode will set the permissions of the file (creation permissions). $mode is required for correct
operation when O_CREAT is specified in $flags and is ignored otherwise. The actual permissions assigned to the created file will
be affected by the process's umask setting as per usual.
RETURN VALUES
A file descriptor or FALSE on error.
EXAMPLES
Example #1
Opening a file descriptor
<?php
$fd = dio_open('/dev/ttyS0', O_RDWR | O_NOCTTY | O_NONBLOCK);
dio_close($fd);
?>
SEE ALSO
dio_close(3).
PHP Documentation Group DIO_OPEN(3)