Welcome, Guest. Please login or register.

Author Topic: /dev/null  (Read 1884 times)

Description:

0 Members and 1 Guest are viewing this topic.

  • Guest
/dev/null
« on: April 06, 2003, 10:48:59 AM »
I guess there is no "/dev/null" on Amiga using libnix or ixemul so what do I use instead if I want to open a "null" file, that is no file at all with fopen("dev/null",method) ?
 

Offline Kronos

  • Resident blue troll
  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 4017
    • Show only replies by Kronos
    • http://www.SteamDraw.de
Re: /dev/null
« Reply #1 on: April 06, 2003, 10:55:46 AM »
"fopen("Nil:",method);" should have the same effect (untested).
1. Make an announcment.
2. Wait a while.
3. Check if it can actually be done.
4. Wait for someone else to do it.
5. Start working on it while giving out hillarious progress-reports.
6. Deny that you have ever announced it
7. Blame someone else
 

Offline xeron

  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 2533
    • Show only replies by xeron
    • http://www.petergordon.org.uk
Re: /dev/null
« Reply #2 on: April 06, 2003, 01:37:50 PM »
why on earth would you want to do that?
Playstation Network ID: xeron6
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16867
  • Country: gb
  • Thanked: 4 times
    • Show only replies by Karlos
Re: /dev/null
« Reply #3 on: April 06, 2003, 01:47:46 PM »
Redicection of stderr maybe?
int p; // A
 

Offline xaccrocheur

  • Sr. Member
  • ****
  • Join Date: Jun 2002
  • Posts: 430
    • Show only replies by xaccrocheur
Re: /dev/null
« Reply #4 on: April 06, 2003, 01:59:54 PM »
W ? You mean creating an empty file, like "#touch file" ?
 

  • Guest
Re: /dev/null
« Reply #5 on: April 06, 2003, 10:03:54 PM »
This is why. I asked how to avoid fdopen() in another forum:

----
>> I need to replace some fdopen with something else or link with some library
>> that contains fdopen. I'm running a crosscompiler on Amiga for PPC and I
>> can't emulate fdopen.
>> Anyone have an idea how I can solve it?
MR> Try using fopen on another file and then replacing the fd in the structure
MR> before any I/O on the file. Not actually legal, but may work if you're
MR> desperate.
Another method: do fopen() of devnull, ask fileno() and call dup2().
It requires fileno() which isn't standard C function, but doesn't require
knowledge of struct FILE internals.
------



FILE* fdopen( int fd, const char* method ) {
  FILE* f = fopen( "/dev/null", method );
  int d, se;
  if( !f )  return NULL;
  d = fileno(f);
  if( dup2( fd, d ) < 0 ) { se = errno; fclose(f); errno = se; return NULL; }
  return f;
}




 

  • Guest
Re: /dev/null
« Reply #6 on: April 06, 2003, 10:07:39 PM »
>Redicection of stderr maybe?


Memory is short.. :)
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16867
  • Country: gb
  • Thanked: 4 times
    • Show only replies by Karlos
Re: /dev/null
« Reply #7 on: April 06, 2003, 11:30:38 PM »
Quote

JoJo wrote:
>Redicection of stderr maybe?
Memory is short.. :)


Not half! Too much stuff competing for my immediate attention this weekend...

In the end I got next to nothing done anyway!

-edit-

You post this before or after you sent me the pmail with the fdopen() replacement?
int p; // A