I am trying to set the terminal attributes of the stdin fd 0 and somehow it is affecting the stdout fd 1 I am

hiya

briefly, what is it?
youtube has a habit of crashing flash and taking my browser down with it

i just do `pkill nsplugin` when that happens. though my browser (konqueror) doesn't crash, it only freezes until i kill the plugin

mm
it usually just dies on the stop
after not responding for a few seconds

ok

but not responding for a few seconds is pretty standard for firefox on linux

i find firefox too sluggish for my preferences

you can grab that script youtube-dl or whatever if you want to download the videos for later viewing, if that's any help
byou can grab that script youtube-dl or whatever if you want to download the videos for later viewing, if that's any help/b

ah that would be useful
i thought other browsers couldn't render html thoguh

"other browsers couldn't render html" ?

last time i tried a few, they tended to render sites wrongly
things in the wrong place or the wrong colour or whatever

s/wrong/different?

if it looks like someone has dropped a handgrenade it's probably wrong
i don't care whether the site is wrong or not

heh

please stop acting like idiots, this is not #coolteenchat

i've come to the wrong channel !!!

Mornin'

howdy.

hey poppavic

hi

welcome to Thursday

Which is almost over.

yes. Thors Day commences

Was thor the one carrying a Trident?

the hammer

'The' hammer… did he have balloon pants?

The Hammer "Mjorn", iirc
Mjölnir
that explains the mismemory

I am trying to set the terminal attributes of the stdin fd (0) and somehow it is affecting the stdout fd (1). I am trying to make stdin non-blocking (which works) using cfmakeraw and setting VMIN and VTIME both to 0. Somehow this changes the output processing on stdout. Any ideas?

of course..

you're changing the tty settings, not the stream

termios function affect the *device*, not *file descriptor*
you could check out fcntl() and O_NONBLOCK if you want non-blocking input
though you probably still want to disable ICANON

I'd be interested to hear him explain what and why he is changing whatever.
I don't even know what VMIN & VTIME mean

you know it won't be a valid answer =P

sure, but it'd be fun to read
I guess he doesn't want to "share" ;-)

http://pastebin.archlinux.org/13169
That is the problem I am having.

that's code, I don't see a problem detailed there

THat's some source - not "problem"

#define STDIN 0, dup2(STDIN, STDIN_FILENO); *boggle*

heh, that's a good one

Ok, there is no longer any output processing on stdout. \n does not behave like \r\n I am not getting a carriage return because something is screwing with my stdout output processing.
Chris, yeah… that isnt there anymore.

well, had you looked in the wiki, you'd have found a couple clues.
You've gone a Bridge-Too-Far

I don't know of "the wiki"

check the topic

Oh, I didn't realize that was a wiki.

The cfmakeraw() function sets the flags stored in the termios structure
to a state disabling all input and output processing, giving a “raw I/O
path''.
well dippy, turn output processing back on mayhaps

!snippets

snippets is http://www.iso-9899.info/wiki/Snippets http://c.snippets.org/

when you fflush(a file), is it guaranteed to have all fprintf'ed data in the file if a program crashes after the fflush was executed ?

arg. I am operating on 0 (stdin) are the file descriptors for stdin and stdout equal?

you are operating on a tty
you are NOT PLAYING WITH STDIO NOR FILE DESCRIPTORS

no

thank you. Could you explain why please ?

because you need fsync()

tty.. pty.. whatever: devices, not files.

fflush just flushes the buffers at the stdio level.
the kernel fs drivers might still cache it

ok good to know
thans
thanks

and even fsync only ensures the drive has it
the drive might still cache

and the function you used just happens to affect both input and output for that device…in case you missed it, read up

ok so no miracle to debug a library which used somewhere else. It it possible that a library behaves différently on different SUN platforms (same OS)?

ok… what do you suggest I read? I am just trying to find a solution. If you want to make fun of me that is fine.

read the little bit I pasted from man cfmakewraw?

anything's possible..

As we still don't understand why you go-do-that-voodoo-you-do-so-well, what would you have of us?

also, it it possible that the application integrating a library messes with the memory used by the library and screws things up without the library being in fault ?

Ahh alright, so I am on the right path… termios… just stay away from file descriptors.

I think some people just come here to screw with us

I'm sure they do, but they sure look funny.

USB in c#

you are NOT PLAYING WITH STDIO NOR FILE DESCRIPTORS. Well, ok… I wont play with file descriptors. I will play with termios…. which requires…. file descriptors.

it requires a file desciptor to find which device to poke

Can any one help me,Please..

that's all

did you check the wiki, as suggested?
c-sharp is down the hall

Yeah, I am looking through it. (the snippets section) not finding the smoking gun. Perhaps I am in the wrong section.

why are you trying to do this whatever it is

"switching stdin's mode on a posix-ish system"

some friend of mine asked me why you have to add ''manually to strncpy but i can't find the page explaining that. someone does?

I want to deal with IRDA through USB

my manpage says: The strncpy() function is similar, except that not more than n bytes of src are copied. Thus, if there is no null byte among the first n bytes of src, the result will not be null-terminated.

if you do this: strncpy(foo,bar,10); and it just happens that bar is longer than 10 chars, strncpy will copy 10 chars from that string, and not null terminate

I try CreateFile()

strncpy is a funny function

so in a nutshell: strncpy does not necessarily give you back a string

C is not C#

indeed

try ##csharp

i know the reason

it's just a misunderstood function is all

but i'd like to supply the page to this dude

let him look at his own

[DllImport " dll"]

geezus.

please, it it possible that the application integrating a shared library (.so) messes with the memory used by the library and screws things up without the library being in fault ? I'm supposed to guess things and it's not easy. The
library works on all our test environments and crashes when it's integrated in a specific application which we don't have access to

wcstok, because I have a joystick that controls a mobile robot. I want to use the keyboard to enter commands without blocking so that the joystick can still control the robot. I know there are other ways to do this (threads for example) but I figured that this would be easier.

so, either put in yourself, or toss out strncpy because it sucks and use something else. i prefer 'strlcpy' which is non-standard but is secure and not uncommon

now the truth comes out…have you considered using ncurses and getch

in C, programs that cause undefined behaviour are capable of just about anything, so yes…
Cahaan, rather.

I use strlcpy too

did you see what I wrote?

have you seen it outside OpenBSD?

thanks Chris. Do you know any way to proove that some code is right or wrong ? or is it an impossible thing to do in C?

proving some code is wrong might be possible… look for bugs

i have; i know that glibc refuses to add it because they would rather punish sloppy programmer with buffer overflows than truncated data

If you can formalize it, you can proove or disproove it.

I did the connection but..

wcstok, yes… but I figured this way I could avoid including another library. Although ncurses does look nice.

Unless you're some random crank like Gödel.

are you listening? hello?

well, I also suspect strncpy is used for copying substrings w/i a string. Folks are supposed to rtfm.

ncurses or termios, it's all the same crap, except ncurses puts a happy face on it

how do you get the directory of the current program running?

I've been doing this since yesterday, looking for buffer overflows, null pointers, lengths, and so son :s Didn't find anything until now

and if you really insist on doing what you're doing, you're going about it entirely wrong

Hello

if you mean the current working dir, POSIX provides getcwd()

no not that

then what are you asking

i mean the directory the program is running on

"running on"?

yes

the directory where the program executable lives?

I didn't write the code myself

if i have a program

http://www.google.com/search?hl=en&q=put+stdin+into+nonblocking+mode+termio+icanon&btnG=Google+Search or I'm sure it's on that wiki Poppavic posted too

called
test.exe

i'd use memcpy or memmove for copying non-strings, but what do i know

then i do test.exe /dodo/blah.exe

What about vid_xxxx&PID_xxxx

i want to get /dodo

lord only knows why folks would use it that way, but I agree

but i cant access the first augument

but since strlcat and strlcpy aren't part of any standard i always provide them myself, although various libcs do include them

so is there another way to do it

I mean deviceclasses in the registry

Did someone use my nick?
This IRC client is bombing.

aha, didn't think of providing them myself

folks could also write a silly strncpy wrapper and do it for themselves.

your question still doesn't appear to make sense. /dodo/blah.exe should be in argv[1]
byour question still doesn't appear to make sense. /dodo/blah.exe should be in argv[1]/b

wcstok, this seems to work though… http://pastebin.archlinux.org/13170

there is also a performance penalty with using strncpy, as it is required to pad the entire destination buffer with

crazy function.

ouchies!

sure, that's the same sort of thing that google search would have found

so really, strncpy handles in the worst possible way on both sides
sometimes it's not there, but if you copy 1 byte into a 4K buffer you get 4K-1 s

i know but how does blah.exe know that

wcstok, ok, I wouldnt say I was doing it completely wrong.

well, it must have been born with some of the Best Intentions. I honestly have no idea what they were ;-)

What about WPF???

I would, newstdin.c_lflag &= ~ICANON; is the important part

and what would happen if you fopen, fprintf, and fclose a file and the crash occurs AFTER the fclose, don't you have the guarantee that the data lies in the file after the crash occurs then ?

it doesn't
do an fsync before fclose

really though, ncurses is alot easier for this sort of thing, but whatever sinks your battleship

ok
thanks
I'll try that

then how do i get the current directory blah.exe is in
with blah.exe

it's highly platform specific, and I've no idea how in windows.

.

heh

hmm

it even seems likely he could con ncurses into seeing the joystick instead of a moose, too.

tell me how to do in linux
because im running this on linux

I've no idea how in linux, but /proc/pid/* may have info
(where pid is the pid of the executable)

o

(and it may not)

What was confusing me, and still might… is that changing output processing on stdin (which doesnt make much sense to begin with…) affects stdout. hrmm. I think I need to read up on how terminals and stdin/stdout all work together

oh
/proc/pid/exe

I still believe it'd be nice to re-partition libc into a few sensible, smaller libs and replace as required. Granted, it would no longer be ISO or whatever

seems to be a symlink to the executable

proc/pid/cwd

no, that's the current working dir

ymmv - I just wanted what I wanted.

he's after the location of the executable being run

oh, nevermind then

could you exemplify two modules?

though, why would you want/need this infor?

Can any one help in Merge Replication over IIS

you don't need to understand how a hammer or a glass is made to use a hammer or replace or wash a window.

Hello there

because you didn't change the input side of the tty, you changed both sides, as that cfmakeraw function clearly documents

What about me

please leave at once

this is a C programming channel.

JUST C

it's likely a bot

yeah?

some housecleaning is never a bad thing; never-ending backwards compatibility as a requirement is the equivalent of never being able to fire an employee even though he does a bad job and doesn't always show up

cool

o i need it cause i need it lol

OK

basically

please do not shout, even if you're a bot.

this is my Q

im porting an emulator to ipod linux
and im running jdarcnes

I'll be damned if that's a Turing test.

i need to know the current directory of program run to load the config file there

yeah, and there is nothing fundementally _wrong_ with the compiler and whatnot - it's the libs and libc that end up making folks whine and whimper.

How can I monitor registry by C

Platform-specific.

PoppaVic, That is true… but when using termios, I do not have a feel for if I am modifying the file descriptor for stdin, or…. what? a tty in /dev? What am I actually chaning and why does termios require a file descriptor. I just like to know the internals a little more so when I come into a
place like this an ask a question I don't get picked on. I don't really mind being picked on but is counter productive.

/linux.bin /mnt/nes/jdarcnes
like that

To "monitor" the "registry" using a C program, which is presumably what you meant, I suggest you write code. Yes, code.

if you read my wiki-post, you'd learn something: and it doesn't _matter_ where it fixes what. It Just Works.

ioctl(2)

C, however, has no notion of this "monitoring" of this "registry", and therefore any pleas for help in this channel will at best web hosting be treatd=ed with polite disdain.
s/d=//

like hell they will…polite, yeah right

try a windows programming channel
what is the one we send people to?

#winapi

#winapi here, #winprog on efnet

but, if you prefer to feel put-upon and don't want our help - fine. Don't the the door hit cha' where the good lord split yah ;-)

oh yes

well, this is easy to explain.

hi Z

you are talking to a device via the file descriptor
hello poppa

wcstok tried to explain that a couple times. Choc wants more, deeper, stronger - from here/us.

Zhivago, what do you mean by device? I am using "read" on file descriptor 0.
PoppaVic, No really. I don't mind where I find it. I just know where to find what I am looking for.

what do you think that file descriptor represents?

wcstok, an open file.

open where?

hey

open where? errr.. the OS? Not sure the answer to that.

perhaps it's an fd resulting from opening /dev/ttyS00 (serial port under linux)…or some similar device
it doesn't particularly matter, just that your terminal is tied to some device that supports that termio interface
and your descriptors 0, 1, and 2 are all likely tied to that device

that's a device — in this case, a tty or pseudo tty.

Ok, so in the case of an "xterm" it is typed to some pts or something like that. If I had a console over a serial port it would be tied to some tty.
typed = tied.

and that's the device that big blackbox of a kernel is operating on when you call one of those termio functions with your stdin fd, or your stdout fd, or surprisingly enough the stderr fd

it's all just a convention — there's nothing special about fds 0, 1 and 2
but normally that's what your program is started with.

Ahh, ok thanks wcstok. tcsetattr basically says "this terminal I am in now (attached to this file descriptor) should behave this way"
And you need to specify a file descriptor because a given terminal can have multiple devices.

uh, no, you need to specify a file descriptor because that's the only way that you can talk to stuff.

hmm, ok. Well I think I about 50% get it. It is more of philosophical question than a technical one…. what is a terminal? heh.

a terminal is an io device.
like a file, or pipe, or socket, only with different capabilities.

Are terminals the only io device with an stdin, stdout and stderr?

/clo

terminals don't have a stdin, stdout or stderr.

ok. I guess I 0% get it Sorry.

this was all raised over termios, btw.

does a socket have a stdin or stdout?
s/socket/pipe
does a pipe have a stdin or stdout?

If I have two terminas (xterm for example) up on my screen… and they are writing text to stdout (file descriptor 0) the text doesnt appear in the same place…
Zhivago, I have never done pipe programming. sockets… have a file descriptor, which I can read and write data from.

ls | more - what is ls's stdout?

in a terminal I know I could set my STDOUT_FILENO to the socket… then anything I write to stdout goes to the socket instead.
Zhivago, I really don't know how that works. I don't know what is happening that causes the output from ls to be redirected to the pipe.

no
it isn't redirected.
ls writes to descriptor 1
what is descriptor 1?

stdout…

no, you idiot.
it is the socket.
or pipe, or whatever
there … is … no … magic … here.

"Any sufficiently advanced technology is indistinguishable from magic." ;P

this is documented. So, it must _MEAN_SOMETHING_ - somewhere.. to someone, neh?
amen
do you know the other term used for "descriptor"? It's "handle".

ls — this prints to standard output agreed? how does ls | know to print to a socket or a pipe? Like I have said I have done 0 pipe programming. ugh. Maybe I am helpless.

it writes to file descriptor 1
ls doesn't know how to print to a socket or a pipe.
it knows how to write to file descriptor 1

if yer building a robot, you can't be as stupid as you act. Therefore, I have to presume you are simply ignorant. Coming here proves you ain't "stupid".

| does not go to ls, it goes to shell.

what a stupid thing to say.

ls does not know what the shell does with its fd 1.

does he realize that every process has their own "descriptors"?

I don't know.
but it should be fairly clear

well..? ;-)

"its" referring to ls, not shell.

I am ignorant in this subject, yes. I think that is a fair statement. The extent of my terminal programming is basically serial port, and printing to stdout. "hello world" sort of stuff.

hi, just wanna ask what is the maximum value of an unsigned long long? thanks

implementation dependent.

see the limits.h and such

but ~0ULL will produce what you want.

ULLONG_MAX and limits.h is the pretty way to do it.

how do i do that?

with your fingers.

do i printf ULLONG_MAX?

Ahh ok, so the | operator prevents the shell from printing to the screen. At the end of the pipe (more) then stuff that "squirts" out of fd 1 gets printed to the screen.

oh, man

as … an … unsigned … long … long.
no.
a | b means that the shell makes a pipe device

| redirects stdout. You might want to redirect stderr as well. Different shells have different mechanisms for that.

it then starts 'a' with the input of the pipe as its descriptor 1
and 'b' with the output of the pipe as its descriptor 0

s/redirects/pipes
So you could redirect stderr also to stdout prior to the pipe.

got it. thanks

There are all sorts of combinations in this area.

if it ain't a meerschaum with some nice vanilla or something flavored smoke, I pass.

stderr.log … or some such.

Ahh ok. a | b | c starts a with fd 1 = pipe1, b with fd 0 = pipe1, b with fd1 = pipe2, c with fd0 = pipe2, c with fd1 = ?

When my pipe process has ended, it is terminated. A new pipe is started… it's stdin is then attached to the bag of tobacco
etc.
by jove, I think he's getting it!

sorta' - I think he's still viewing it askew

hence getting over got.

c with fd1 = the terminal's output
what about a /dev/foo?

Here is a simplified clue: Every C program bootstraps with 3 fd. They are _always_ called "std{in,out,err}" - in that order. Everywhere. Forever.

even though they are actually 0, 1, and 2

eek, not sure of the terminology… but a's fd0 is getting set to… whatever is called. a reverse pipe?

no, that's jut the standard.
it isn't a pipe

we call that redirection

yeah, I'm mixing FILE* and fileno - but it's true

0 is not necessarily stdin. it often is, though

a b means that the shell opens the file named b, and runs a with that file as descriptor 0

portable way to get the fd is to use STDIN_FILENO in unistd.h iirc

oh. whatever.

it would be better to say it is, _by default_

what system doesn'd have it as 0, 1, and 2?

unix

well, it doesn't matter what it really is - just that they correspond. Forever.

what?

it's just a convention — consider some suites which use fd 3, etc.

a convention?

yes, a convention.

yeppers

where!

Ok, so lets say that "a b" and a wants to read a keypress. How would a accomplish this?

posix.
a reads a character from descriptor 0

C is mostly conventions. We trust them, or we read big, fat, flashing-print documents.

a b means that the shell opens the file named b, and runs a with that file as descriptor 0

yeah, so what?

reading for fd0 would read from the file not the keyboard right?

oh.. I see his point.. He needs to reread that wiki section I posted.

PoppaVic, let me make sure it is the right section… http://www.iso-9899.info/wiki/Snippet_POSIX_STDIN_mode

nothing specifies folks will enter main() with the console as fd0 - nothing. Hence the next post I made following that one, ala' mauke

it reads from the open device associated with fd
er fd0

which section?

If I convert some fortran code to C with f2c, then want to compile the program so i can distribute it to other linux boxes that may not have libf2c can i do that?

what?

just make sure its statically linked

which section of IEEE 1003.1

Ok, so fd0 and fd1 can read/write from sockets, pipes, redirections, etc… when a program is started normally (no pipes, redirections, etc) 0 is read from the keyboard, 1 writes to the screen. What controls/is in charge of/etc where data written to fd1 goes? the kernel?

what are you babbling about?
wrong.

matt__ how do i do that? I did gcc *.c -lf2c -lm

there is no keyboard, there is no screen.

what are you looking for?

he mentioned 0,1,2 being a convention

whoever started/executed the program: the other is an assumption.
there is no spoon ;-)

-static
will force it, if it isn't already linking statically

the shell starts the program with fd0 being the output of the terminal, and fd1 being its input.
just like a pipe, or socket, or whatever.

ok, that makes a lot of sense.

good

and, like everything in UNIX, the terminal and the keyboard are in /dev and are 'files'

matt__ thanks that seemed to work

*yawn*

So the shell basically dups the keyboard to fd0?

look for whatever specifies STDOUT_FILENO

doesn't matter, Chocobo - how's that tempered-glass hammer coming? ;-)

lol. pretty well

dup2() perhaps, but the shell generally inherits it via its fd0.

Ahha, still that is not a "no" So it means I am slowly understanding.

you basically woke the Sleeping Giant, and you are getting a lesson that would take at least a season to experience in peace ;-)

PoppaVic peace & serenity "_^

lol. I love the giant

fine
all of this is waaayyyy overkill for dealing with a keyboard+joystick interface to your crawler.
I'm not sure how you read the joyjoy, but the rest was easy the first time.

http://www.opengroup.org/onlinepubs/009695399/basedefs/unistd.h.html seems to indicate that those things are required to have particular values…

brb - recycling.

and what does it say about what those descriptors must refer to?

I think I need to read the ISO C standard to find that out

ISO C standard can't answer that question.

it might tell me somethign

well, All I know is that the 0,1,2 handles have been the same since my TC/C++ days.

until you start to deal with qmail or something which uses 3 instead

Perhaps the POSIX standard?

matt__ im getting a problem on another machine when I bring over my statically compiled program it says "kernel too old, seg fault"

that's ok, but "stdin" is zero - does gmail open 3 as "the keyboard" or what?

that's an issue unrelated to libf2c

all I ever meant was that stdin was zero. Period. We don't _know_ if the human types it, a program feeds it, etc

oh, wait, it says right here…

maybe f2c doesn't work on that box because it needs a certain version of the kernel?

yesyes?

http://www.opengroup.org/onlinepubs/009695399/functions/stdin.html

define the file descriptors that shall be associated with the C-language stdin, stdout, and stderr when the application is started:

loading

oh crazy
standard error is supposed to be readable?

not that I know of
I was just pondering why it wasn't 2,3 for signaling,erring

signaling?

the inverse idea of stderr

oh

since stdin/stdout complement each other

you mean so the user can tell the program about errors?

heh

yeah.. Neat idea ;-)
Talk about event-driven ;-)

Each application gets it own fd0,1,2. how to word this… Does the kernel maintain a lookup table that says if "a key pressed in the terminal, send the data to this programs fd0"? I hope I am using the correct terms here. Same with writing: "This application wrote to fd1, that goes to this
terminal.."

it-doesn't-matter
Forget the kernel. /bad/ llama

well on non-POSIX systems, you shouldn't rely on having fds…

ou have it backward.
the program does the reading, data isn't sent to it.

on POSIX systems the kernel must surely have some way to figure out what fd is what

Is there a such thing as non-POSIX os?

windows

you may've heard of it

It was a joke pizza_

they might have a real posix subsystem now, but only posix programs can use it

Ok, anyways I will stop bothering you guys with this… it will make you angry at me Thank you all very much for the help.

dammit
graphviz isn't thread safe
shame on whoever made it

sounds like a fun project, go for it
AT&T Research

I'd never worry about "The Kernel" - I _might_ write a daemon to support a program.

bunch of newbies

graphviz has issues, unfortunately

"issues"?

never hoid of it. I've used gnuplot.

like sometimes it crashes or uses an inordinate amount of resources

thread safety is generally a mistake.

Its for laying out topological graphs and rendering them
dunno if gnuplot can do it

heya fax

hi
Why is that?

why is that?

lol

I was busy taking gold bars out of square holes I was digging yesterday, i'm rich now

since you feed gnuplot, I dunno why not?

excellent question sir

There's surely nothing bad about being reentrant
lmao

Oh, I am not worried about it. I have no intention of modifying it. I was just trying to figure out how every application can have an fd0,1,2.. and have everything go to where it supose to.

well, that's a different matter

I suspect Z means that thread-safe is automagical if you are reentrant

to be fair I don't really know the issues.. I've avoided threads in all but one program

Folks and their "thread-safe" mutexes and stuff get scarey

I can't see why writing software to be thread safe is a mistake though… unless I suppose if it hinders you

hell no — re-entrancy doesn't imply thread safety
because it requires you to make a bunch of bad decisions.

basically thread-safety requires the callee not relying on static data; usually having the caller pass its own copy of data (structures) instead
bbasically thread-safety requires the callee not relying on static data; usually having the caller pass its own copy of data (structures) instead/b

yeah passing around state seems like a good thing to me..
compare embedding Lua in a program to Ruby

Muahahahahaha, regexps are avoidable
http://www.solemnwarning.net/code/compare.c

pizza_, or you can use mutexes

Lua is much much better because they pass state around, instead of having everything static/global

whom? why?

PoppaVic, where and when?

yes i suppose i should have said "avoiding unchecked access to static data"

you made the stand: protect it.

pizza_, that's one way, and not sufficient by itself

I still don't see it :|

PoppaVic, have your testosterone levels checked

you are not saying passing state around explicitly is a bad thing are you?

literals are literals. Values.

what does thread safety require

you can only call functions which are thread safe, everything which references an object you might destructively modify must be conservative about its access to it
I think thats all

twisted

meaningless gibberish

ugh

sounds like circular logic to me
what makes a function thread-safe?

you can call it from multiple threads and it doesn't "break"

and what does that require?

this is a good thing.

it means functions might be threads, and threads feel they OWN the universe. So, either they own the universe or they all agree to conventions like flock and mutex, etc.

stop avoiding the question

I am not I answered it

"Programming with POSIX Threads" by Butenhof (Addison Wesley), and "Programming with Threads" by Kleiman, Shah, and Smaalders (Prentice Hall) are both great

I think the two things I suggested are what is required for thread safety

you provided no information whatsoever

I have to agree with the others. Yer scaring me.

"being thread-safe means you only call thread-safe functions" "being thread-safe means things work with threads"

I'd point out that a process is not a thread and a neither is a "function". So, yer in trouble using loose terms.

maybe you don't know, you can just say that, i'm sure someone could help you understand it

I suggest that it's meaningless gibberish

ok then please explain to me
seeing as my answer makes no sense to anyone

thread safety is about the propagation of messages between identical objects.

do you know what a thread is?

essentially, you can reduce it to transactions — either optimistic or pessimistic

I used the term conservative where you said pessimistic

uh, they mean entirely different things here.
a pessimistic transaction assumes that it will be aborted, so pre-negotiates not to be.

Hey everyone, is this the right place to ask about the c++ stdlib??

yeah!!!!

down the hall in ##C++

thx

so what are the conditions for thread safety them?
then*

what is a thread?

a fine cord of twisted fibers (of cotton or silk or wool or nylon etc.) used in sewing and weaving.

there are several uses for the term "thread" - and they disagree

someone paid attention in home economics

The context is programming - that's all we have agreed ;-)
it's not nice, but (there is no easter-bunny) ;-/
I still despise setjmp/longjmp

I'm still clueless as to why writing thread safe code requires you to make bad decision

what folks roughly implied is: there is no spoon.

thats fair..

i would generally define a thread as something like: an execution context within a program that shares memory with zero or more execution contexts.

Given a single processor, there is a single kernel. Processes run in their own space by voodoo specific to the kernel. Now: what is a 'thread'?

ok, that makes sense

ok, and furthermore, the scheduling and execution of these contexts is controlled by someone other than us (probably the kernel)

there are two forms of 'thread': kernel-space and user-space. Which would you want to tackle?

hm yeah thats a good point
I was assuming the same issues applied to both

meaning that execution contexts can start and stop at any step along the way; in some situations none may be running, sometimes 2 or more may be running at the same time

We already have a multi-tasking Kernel. But, the issues are NOT the same and the expectations seem to pretend/assume a lot.
well, "same time" is another issue, because folks are so much slower than a processor - let alone multiple processors.

so i guess i would define a thread-safe program as one that doesn't make any assumptions about the state of any of the other threads or their resources

or a thread safe function is one which you can call from multiple threads, simultaneously .. and its execution is well defined?

many of them do

yes, but let's look at what that means

You'd really need to clear yer head of preconceptions.

many do what?

you need synchronization

many of the same issues apply to both user- and kernel-space threading

only when they communicate

except user-space threading also has to deal with inadadequate system facilities

ah ok

Z was write by mentioning "transactions"
right

in order for a function to be safe to call from multiple threads it must be guarenteed that any data it uses isn't in use by any other thread (since we can't guarentee the state or status of other threads)

well if all a function does is call a sequence of other thread safe functions.. then it is also thread safe

as well as not being in control of the system
whereas kernel-based threading has to talk to the CPU

there are systems where a "transaction" is interrupted, and others where they are interrupted before/after.

so, either each thread has its own copy of some data structure or buffer, and each instance of that function operates only on that dedicated resource

if the function writes on some object which other threads may possibly have a reference to, it needs to lock on that
there is nothing else to it…

no

how am I wrong?

or access to shared host resources is serialized so that each thread waits its turn to allow other threads to arrive at a known, good state before accessing a resource

that's a mutex, that's sharing. That's another issue

yes true

don't even _think_ about "sharing" until you nail down whom/what.

ok so I did know what thread safety was :/
and the conditions for it.
What I don't know is why that forces you to write bad code

what makes a function thread-safe?

what kind of answer do you want?
I've given three arleady..

a single sentence that generally describes the conditions that must exist inside a function to guarentee thread-safety.

I believe the issue is still process/thread.

A thread safe function can call any thread safe functions unguarded, it must gain exclusive access to any object that may be shared between contexts for a read or write… and not make assumptions about shared objects like they will not be modified

no

enlighten us
big poppa

is that no as in what I just said is wrong?

I answered too fast, then wanted to apologize - but I read more and it's still flakey.

perhaps you could offer an alternative definition you find more robust

we can sit about all day defining this…

fax's response seemed adequate to me

here's a better question… Z is right, and it's "transaction" based. How would root your def in terms of "transactions"

but the issue is Why does this cause you to write bad programs
or make bad descisions whatever

sorry, trying to do three things at once, but look at it and think "transactions"

well a transactions is a read/write on an object that may be shared between contexts
so you can wrap that in a mutex -or- write a function to access the object and put the mutex in there… so you have a thread safe access function

what does thread safety require

let's explore "contexts" for a sec.. Kernel? userspace?

all that is left is that you must not make assumptions about the object… e.g. this object will not be modified
I think (hopefully) what I said applies to both

I think yer close, fax - unless we are miscommunicating
what about read-many/write-one?

of all the people in this chan you are surely the best at avoiding a straight answer

thread safety is generally a mistake.

I don't know the significance of read-many/write-once..
we covered that!

I am in error? Fine. I'll bow to thee, now explain it all

about 5 times
:p

Did Zhivago ever say why he thought so?

read-many/write-once is just a series of transactions, no?
I'm hoping he will ..

queued requests

no, you just complain and switch subject instead of ever providing what you think is a better suggestion

priority-requests are possible

Reading the backlog, he hasn't explained himself.

dude, if you know all about "thread safe", feel free.
I think he left it as a debate for a reason

ok I think [with a stretch] we can fit queued requests into Don't make assumptions about the state of other objects that may be invalidated

thread safety is generally a mistake.

personally, I'm not buying his statement.

All I'm seeing here is things like encapsulating state, encapsulating access to shared objects… it seems all like good programming style to me
well thread safety implies threads
and threads themselves are a mistake :]

well, I tended to smile at it - but he and Xgc certainly get paid while I do not.

don't suppose anybody knows of a way to make fopen case insensitive?

it is

where do the capsule boundaries belong?

run it on windows =P

your filesystem might not be

:p

It depends on whether you have really good reasons for a threaded architecture. There are some good reasons.

stop expecting that with files.

all perfectly valid answers, but not really helping

for instance, apache httpd and performance.

it's not our prob: I learn to spell and search

I'd put em with the definition of the object I guess

why so abrasive?

he was dropped as a child
a lot

you must be new here

You haven't understood what I said..

no, i have

Then you either already knew the answer or don't care…

I'm not "that kind of guy", and folks should expect to exactly write filenames and paths, or suffer other/slower interfaces

assuming by 'capsule boundaries' you meant thread safe version of object accessors

A filepath or filename should be as goddamned exact as "10"

versions*

if you want it to be case insensitive, use Windoze.

that's the OS from m$ right?

oh be quiet

he can do toupper/lower, or exec locate *|grep -i, etc

go away and read http://web.textfiles.com/ezines/KRAD/

thread safety is easy - just block all other threads from executing while you are doing something :P

heh

there is a lot of hate here

Even the case-insensitive osX manages to get it right. Go learn how and why.

don't take it personally

you were talking about encapsulation …

don't worry

maybe you want open/readdir etc .. you can write you own find file with name similar to

where should those capsules be produced?

hmm, that's an idea

well I don't thinks its a requirement that you encapsulate the data you deal with, just the way you access it

umm… doesn't that access suggest agreements?

what kind of agreements?

basically i have a portable filesystem abstraction layer that should be case insensitive (since it's portable and windows is the lcd), but it isn't

well, you have yet to define a process or a thread. What's yer view? Does 'more' need to agree with 'joe' are those process or threads? etc.

you just said that it's good practice to encapsulate it …
so, where do you place those boundaries?

I already know *I* don't always satisfy others herein, but I try to agree when I learn what they are speaking about.
I think Z's "transactions" are the kicker

is that so

where it makes logical sense based on the requirements?

hi

I don't think there are agreements, it is more like waiting in line for somthing
you can choose to wait in the line.. or you can just deal with what you're doing

uh, and what is that 'something'?

What exactly do you mean by boundaries?

well, thanks for your comments, everyone

something being read/write access to a shared host object

Zhivago must have me on ignore, how unfortunate

my sympathies, if true: Z may just be tunneling on fax.

you're not saying anything meaningful.
why do you think there is one way to divide it which makes logical sense?

i politely asked you to elaborate on something you said which launched a long conversation

hi, do you have an idea of a call to set the numpad to numbers or cursor keys in X11?

well, you tried to shaft me in the same period. I'll just watch ;-)

yes, and?

man xmodmap

and could you?

so, every individual read-write is individually waited for?
I have been.

it must be
the waiting time may be 0 though

Zhivagooooo
ooo
o
..
woops, public :P

matt__, umh, does it have a C interface?

that was just stoopid.

i see, how unfortunate. well, thanks for responding.

well, that's obviously gibberish
what if two of those read-writes depend on one another?
yes, it is unfortunate.
will waiting on each individually work?

two from separate threads?
or from a single thread

what would it matter?
the number of threads is irrelevant to how you divide things up at compile-time.

ah, off we go into race conditions and deadlocks.

it would work fine if they are in the same thread
if they are in separate threads then it will be fine also, but you must not make false assumptions

meaningless gibberish.
the code isn't in threads.

the execution of the code is performed in the context of a thread…

so, obviously the way you divide up the waits for reads and writes must be independent of the number of threads at run-time.

yeah

well, the topic became "thread-safe" - and both are subjective anymore.

so, start thinking about it properly.

hmf

ain't "threads" fun? ;-)

I don't think I will understand this without coding some threaded program bigger than a few thousand lines

no

do you believe thread safety to be a mistake because you believe threads to be a mistake?

You want several forms of threads and then a better idea of threads/threading
writing a simple program is easy; threading seriously screws yer day, regardless of what/what.

I didn't say that thread safety was a mistake, per se.
fax's argument is that you should write arbitrary code to be thread safe.

iirc, you implied the term was bad.

because this is somehow more correct.
no, I implied that it was stupid to do so unnecessarily.

ok

thread safety forces premature decisions about many various semantics.

I already know it ain't "friendly", because of multiple factors.

I've written smaller programs which process stuff from queues in parallel

you need to decide how to divide code up for parallel interaction.

PoppaVic
I don't think I'll grasp the reasons for this without seeing something deeper

sure, listen to Z - he's got a clue, and I can't see a reason to argue him.

that's because you haven't answered about interdependent read/writes.

I did not find it clear that you thought is was stupid to do so unnecessarily, although I inferred it, I wanted that clarification. I have no problem with such an assertion.

even simple programs get multiprocessed anyways on modern archs

So, thanks for clearing it up

well, remember - I can suffer "detached threads" - I don't care where they run, kernel or user spaces. The moment they are supposed to interface all together, I start thinking of deamons/drivers or other solutions.

welcome.
you may be confusing programs and processes.

i was actually thinking of pipelining

unless you're confusing this with branch prediction, and so on.
then that's incorrect.

well, I tried to suggest the idea/defs early. If folks think it's all voodoo, we can't help them

interdependent read/writes can cause a mutual lock between mutexes

the program isn't multiprocessed in any logical fashion.
only if you're stupid enough to use separate mutexes for them …
and if you use separate mutexes, then you need to use additional mutexes to handle the interdependent cases

threading is the worst.. Coprocessing is bad enough. If folks can't believe in "a processes and state/time-slice" they are in a world of hurt.

so, the simple answer is that you can't use one mutex per read/write independently.

Hello

I personally don't much care if folks get silly. I just try to do what I do ;-)

you need to structure the code into essentially independent chunks

maybe, it depends on how we define multiprocessing

it's _always_ dependent upon the defs/agreements.

How can I ( in C Language ) detect the OS ? ( linux based hosting services or windows ). Have you a partable method to do this ?

we define multiprocessing in terms of how things interact.

ask the user, and assume they lied to you

pipelining and so on are transparent to how a program interacts with itself.

do you have a single compiled binary that runs on both?

no, it's worse… There are bolks and schools and folks that twist it all.
bolkds/folks

yeah, it depends on where we draw the line of abstraction

well, that and a dictionary we all agree upon

#ifdef

pizza_ ? non
fax , not in compilation , I want to do this in execution

No.

?

"?" is not a question

it's a PITA, and I'm much too old to keep guessing or using ESP on folks.

No ?

Because you can't

do you have a single compiled binary that executes on more than one major operating system? if not, this is not required; you can specify it when you compile host them seperately.

Ah yes I have a single compiled binary that executes on more than one major operating system

the word "multiprocessing" is probably wrong in the context i'm using it, but i note that there are similar problems in that level of abstraction
interlocked pipeline stages, for example.

I found this http://bama.ua.edu/cgi-bin/man-cgi?uname+1

then i guess you would identify them using the simplest, most reliable way available
on which operating systems does this binary execute?

is that even possible? a linux/windows compatible binary?
the closest thing i've seen to that is mac os x's ppc/i386 loader dealie

Linux/windows

he's just being silly
ignore hmu

it's not against the laws of physics, just the laws of thermodynamics.

wine whine

I suspect the issue is that folks want to speak of C, and then speak in terms of CPU and platforms, etc: it's just silly.

using WINE on Linux?

using Windows

WHINE on linux

or using cygwin on Windows?

pizza_

I would understand if folks wanted to speak of the ENGINE/vm or FFI - but they want to pretend C is the OS or the OS is C, and blame someone. Well, C does what it sez. The idea of threads and shit came along later.

I found the uname funtion to have information about kernel, but for using uname() I must include sys/utsname.h
and there are not utsname.h under windows
pizza_
I must use cygwin then ?

under C, there is nothing like a "pipeline stage", etc. Just don't confuse it all - the "pipeline" is the issue you are taking.
C has no idea of "registers" beyond "register" variable-suggestions, let alone stacks, heaps, program-space, etc
I agree it's not ideal, but there yah are.

i will say this one last time, and no more. you do not possess a single binary that runs unaltered on Windows and Linux. you may have source code which is compatible with both (congratulations). when you compile your app for separate operating systems, i suggest you #define a preprocessor
token identifying the OS (Windows headers define WIN32 for example), and use preprocessor logic.

he's just being awkward on purpose.. leave him be

hehe - you got heated/irate ;-)

that's the plan

Ok, thanks pizza_

oddly, Bug_Bug may be thinking of pcode/precompiled-code: and is too stupid to note there is a diff.. I've seen that with even asm-heads.

i have void function and i'm calling it once.. but it keeps saying "warning: conflicting types for consume_and_sleep" last declared on line 50 etc

you're welcome

well, fix it. It's "easy"

are you calling it before it is declared?

pizza_ well i have it declared in the deader file
s/dheader/header

you don't "call code" in the header

i'm not

if the definition of the function consistent with its declaration?

copy and pasted

Some days, I really, really look forward to the bugs inheriting the planet.

if you can produce a test case and pastebin it i'll take a look
!testcase easytiger

A testcase is a minimal compilable example exhibiting your symptoms. Please paste a testcase at http://rafb.net/paste to help us assist you.

well, not that yours will be compilable, but please strip out anything unrelated

it compiles and runs perfectly. its a warning

warnings are a fact of life - did you try it on another system?
Mind you, warnings should be respected and fixed like errors, (usually).

well you're obviously defining it differently than it has been declared, don't know what else to tell you; perhaps an error in the header file causing strange behavior?

maybe an expectation in the header?
in/of

http://rafb.net/p/6ZaLrr41.html - main()

where is uint16_t defined?

stdint.h

http://rafb.net/p/jrcs3W92.html - header

OK. I give.. Have a great day/knight, folks.. I'm folding. Stay well.

there are some more libs i have too. but they aren't the problem

ok, that looks ok

would prefer no warnings. just can't see why
mem-tool.c:83: warning: conflicting types for consume_and_sleep
mem-tool.c:63: warning: previous implicit declaration of consume_and_sleep was here

what is on line 63?
and line 83?

consume_and_sleep(bytes_perc, sleep_t); [ func call]
void consume_and_sleep(unsigned long int size_b, int t_sleep){ [ funct definition]

you need an appropriate prototype of consume_and_sleep before you call it.

yes. its in the header file

well, try including the header file that it's in

are you sure you're including the header?

well you can see the import int he code i pasted

sorry didn't see that second paste

os.h?

thats it yea

provide a paste of that, too.

he did

oh

http://rafb.net/p/jrcs3W92.html

hmm, i declare shenanigans
it compiles for me

it compiles for me too Chris.. but with a warning

sure
i mean without warning

:/

there's a bunch of _other_ problems

maybe my makefile

but none about the consume_and_sleep problem

yea… they are fixed now

right

and your missing linux.c

yeah
but that doesn't stop me compiling that
it just stops me linking

what compiler?

gcc

gcc (GCC) 4.1.2 here

right
what does your Makefile actually invoke?

gcc -o mem-tool mem-tool.c linux.c

shrug
it's not a gcc issue

Hello.

you're doing something else weird
do you get any other errors/warnings?
hi

maybe there is another os.h in a different path and your app is including that one instead?

maybe

yay, lots of warnings / errors with my compiler.

you can't hide from the GNU

the_plumber, You're right, most GNU code uses GNU extensions that only GCC understands because Linux coders are a bunch of fucking noobs.

i changed it to wos.h and it worked.
but i can't find another os.h
:o

Linux itself uses those extensions because it needs them

that's funny, because i was on the verge of asking you to rename it just for kicks, but hesitated

well, I mean, I suppose they could have used more assembly code or something…

needs, heh

anyway.. lesson learned.. dont call my header os.h

yup. so do you now know the actual cause of the error?

i can't `locate` an os.h anywhere on the system. it just went away when i renamed it
but it had to be picking it up cause i had declarations in there

are you running locate as root?
actually, maybe that doesn't make sense

damned stallman
heh

See updatedb

HEllo
I would like to monitor what signals are being sent to an already running process. How can I do it?

ptrace maybe?

hi there

hi…

right
this is FreeBSD
so ktrace

Deesl, ktrace is a user-land utility that uses the ptrace syscall.

oh ok

hi, do you have an idea of a call to set the numpad to numbers or cursor keys in X11?

on linux… someone knows about that ?

lol, #bash told you to join a fucking X channel hours ago.

tj__, Have you tried sys/stat.h?

don't hesitate to say my question is not precise enough

trash, do you think I didn't? I tried xorg (no answrs the channel is desert) X11 X or similar don't exist, #gnoem #kde
no answers
now I gave up looking for an utility and I am searching for a C call to Xlib or something
and, to be honest, I already asked here hours ago, and I was told to use some utility

-_-; I completely forgot about that detail lol

which utility?
sys/stat.h should work on both windows and unixes

forgot everything, I'm so stupid

well, you use apostrophes, which is more than a lot of people can manage.

Amazing. Well huuuuh…. thanks for all ^^; I'll try to be brighter next time XD

Cheiron, xmodmap but I cannot find how to do that

thanks for all bye the way. Bye

i don't think xmodmap would be what you want

anyway, I should call xmodmap with system then so a direct call would be better

well, if you can work out how to do it in xmodmap, you can just look at the xmodmap source
maybe xmodmap is one way.

Chris, do you have any other idea?
sure I can watch xmodmap sources but

no
X is scary

first I have to understand if xmodmap can do that
ok
thanks

Hello

hi

im trying to share a FILE* between a app and a lib and im failing miserably. when i try to use it in a fprint i get a segfaul.
i have extern FILE* in the lib
and just a normal FILE* being opened in the app
anything wrong there?
i keep getting Undefined symbols

just pass it as a parameter

id have to be passed to a crapload of functions then
seems kind of annoying

You could just pass it once
have FILE * my_library_fd; in your lib.c
void set_file(FILE * f) { my_library_fd = f; }
then all your lib functions operate on my_library_fd

you may want to declare my_library_fd static, too.
unless you want the app seeing it directly.

and extern it in the other lib files?

No
use your functions
or stick it in a header

ok, ill try that. thanks

hello

i'm having a problem assigning a signal handler to a sigaction structure. My compile host keeps throwing the error: display.c:57: error: request for member '__sigaction_handler' in something not a structure or union
struct sigaction sa;
sigaction.sa_handler = display_resize;

laetus, shouldn't it be sa.sa_handler = display_resize; ?

oh crap, lol
doh!

happens

sorry basix, i'm having a homer simpson moment

where can i find out which registers are used by certain system calls on linux?

in the linux source.

they all use (prefixes of) the same list of registers

i vaguely remember linux changing its system call stuff somewhat recently, too.

what does that mean?

from int 0×80 to syscall

I expect both work now

right

i mean, register eaX used to pass filename
such an information for exampl

bbl

well, the information is in two pieces I think
there's a list of registers used on your architecture, and information about how to use that list to issue each call
see your headers
I think

hi http://www.pastebin.ca/668285 –could someone help me with this? im trying to compile this with cross compiler h8-gcc-elf

frog, firstly, don't use __USE_BSD, proper define is _BSD_SOURCE.
-W -Wall — but I would go read proc_fs.h to see why it breaks.

hi, I have a problem trying to translate a java program into c++, as I want a function to return arrays of objects(which I recon is impossible in C++) but have no idea on how I should work around this. I'd appreciate any help that addresses this issue.

ok, Auris- thx, gonna try… proc_fs.h seems ok

and where does C fit into that story?

:

frog, it can't be okay if there's an error.

well truly it is a C++ problem, but the thing is C++ and C should be indistinguishable in just that

get out while you can.

c++ sucks

Auris-: i guess, that the headers from kernel are messed up with the headers from uclibc anyhow

we had agreed on that

that's just so convenient

java rots your brain, makes differences hard to see.

they most definitely are not in that particular thing

or an array allocated with new[]

Yacc rots your brain

in C you use malloc

oh well, I'll see a c++ channel then

or if you wanted to be hideous, you'd return a struct that contained the array

Hello folks

you have friends?

RadSurfer :/

Cygwin is POSIX complaint. Yeah sure. whatever.
Compliant

tries, anyway

It misses the "fork() executes fast" bit, though

yeah.

I've had programs spendi 40% of their time forking

snarled my compile yesterday, lol

I'm trying to write a cgi to e-mail a form. So far, the cgi parsing is Ok, but I don't find any references for the mailing part. Could anyone guide me or provide any source for me to read?

Wait, what, in C?

Yup

most people just spawn an external MUA

That's horrifying

mactimes, why not just invoke sendmail ?

but then, most people don't write CGI stuff in C
if they can avoid it

*Nobody* writes CGI stuff in C
If you absolutely must have C, it's for speed, and then you don't use CGI

Cause I don't know how to do it =(

man sendmail

well, it's okay if you write something in C and it takes enough CPU to make the CGI overhead negligible

Then you can write the CGI part in a better language and call to C for the cpu-intensive parts

mactimes, try Python ( dont flame me people ). In C you'll have to start from scratch i.e. opening, maintaining TCP/IP connections, implementnig SMTP and the required error handling etc… etc… If you wanna do that, then go ahead…

www.ietf.org/rfc/rfc0821.tx

No reason to implement, or even touch SMTP, really. Just pass it to your local MUA.

Ok, folks, shall we keep focus on the problem? I'm not looking for another programming language. C is an outstanding one and I know it is possible to do it.

you shouldn't have to worry about network connections in general for CGI unless you're doing something in particular with them

I'm just looking for material to get started in the mailing part.

The only people who think C are outstanding are the ones who haven't learned any modern languages

afaik all the information can be found in environment variables and on stdin

read up on sendmail, and shell to it. sheesh

mactimes, see what Baughn sugested or else check out a library which implements SMTP

don't

That's what I'm looking for

mactimes, definitely C is a outstanding language but it has its uses…

just dig the basics from the rfc I pasted , or read some smtp protocol 101 tutorial

mactimes, i did a similar app in python. it took hardly 15-20 lines

Just like any other PL
I will, right now
Errr.. Page not found?

http://www.ietf.org/rfc/rfc0821.txt

mactimes, www.ietf.org/rfc/rfc0821.txt

Thanks everyone.

if it were python, we'd be done by now
meanwhile, who else got LOTS of rain today?

sunny today

it rained all day yesterday

you just had to send it this way, eh
thats ok, the house that burned down, down the street should be out by now :-)
bthats ok, the house that burned down, down the street should be out by now :-) /b
I'll check in later kiddies.

Blegh

Errr. Folks, I have finished reading the rfc. The problem I have now is, I made a simple test with my mail server and I think it requires an authentication and I don't see any SMTP command to do that. What should I do then?

look for additional rfcs

Thanks. That was very helpful. I don't even know how to demonstrate my appreciation for your support.

how can I get the returned string of a dos ( or shell… ) commend ? in C language … system("ver"); for exemple

those things don't return strings

 Personal Web Hosting | Personal Hosting

*
To prove that you're not a bot, enter this code
Anti-Spam Image

Leave a Comment

You must be logged in to post a comment.


Blog Tags:

Similar posts: