* executing code under a child process and another tcp question @ tyler ` Chris Norman ` Garry Turkington 0 siblings, 2 replies; 5+ messages in thread From: tyler @ UTC (permalink / raw) To: Speakup is a screen review system for Linux. Hello everyone,, Though these questions may bwe boardering on the relm of programming, I wasn't really sure where else to ask them, I am aware of the blindprogramming list, but don't like to sign up to lists with high traffic like that one, because sometimes its hard for me to check my email, and when I get back (just from being on the blindgamers list, and the three lists owned by the same organization as the programming@blindprogramming) after not reading email for like 4 days, I had over 700 emails. Anyway, I have a couple questions, I read up on fork, and found that it isn't just something used to eat your food with, but you can spawn other processes with it. But, my main idea was a pipe, I wanted to spawn a child process, and create a pipe to it, so I read up on pipes to. The only thing I have been able to find is how to get my process to execute shell commands, Do I have to stick to shell commands, or can I actually switch execution between child and parent. Also, how do I get the pid of the parent process? Last, I want to start playing with TCP. If I send in the raw mode, can I just send a struct as a packet? If so, that will only take me reading up on how packetts are formed (I know the basics) but not the exact ways, and then I can just create a struct to represent a packet, and send it to where ever I wish. I also as a little example wish to create a ping program, and a port scanner, I can do the port scanner fairly easy I think, with minimal research, but what does the ping program do? I haven't been able to figure that one out, and I have used numerous packett sniffers. Things just look garbled. Thanks for your help, Tyler Littlefield. Check out our website: http://tysplace.the-leetest.net check out my blog: livejournal.com/~tylerrl [my programs don't have bugs, just randomly added features] [failure is not an option, it comes bundled with windows!] ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: executing code under a child process and another tcp question executing code under a child process and another tcp question tyler @ ` Chris Norman ` tyler ` Garry Turkington 1 sibling, 1 reply; 5+ messages in thread From: Chris Norman @ UTC (permalink / raw) To: Speakup is a screen review system for Linux. I don't know about code execution, but if you want a really "worryingly" good network sniffer, get NGREP. HTH, Chris Norman <!-- chris.norman4@ntlworld.com --> ----- Original Message ----- From: "tyler" <compgeek13@gmail.com> To: "Speakup is a screen review system for Linux." <speakup@braille.uwo.ca> Sent: Monday, March 27, 2006 6:00 PM Subject: executing code under a child process and another tcp question > Hello everyone,, > Though these questions may bwe boardering on the relm of programming, I > wasn't really sure where else to ask them, I am aware of the > blindprogramming list, but don't like to sign up to lists with high > traffic > like that one, because sometimes its hard for me to check my email, and > when > I get back (just from being on the blindgamers list, and the three lists > owned by the same organization as the programming@blindprogramming) after > not reading email for like 4 days, I had over 700 emails. > Anyway, I have a couple questions, > I read up on fork, and found that it isn't just something used to eat your > food with, but you can spawn other processes with it. > But, my main idea was a pipe, I wanted to spawn a child process, and > create > a pipe to it, so I read up on pipes to. > The only thing I have been able to find is how to get my process to > execute > shell commands, > Do I have to stick to shell commands, or can I actually switch execution > between child and parent. > Also, how do I get the pid of the parent process? > Last, I want to start playing with TCP. > If I send in the raw mode, can I just send a struct as a packet? > If so, that will only take me reading up on how packetts are formed (I > know > the basics) but not the exact ways, and then I can just create a struct to > represent a packet, and send it to where ever I wish. I also as a little > example wish to create a ping program, and a port scanner, I can do the > port > scanner fairly easy I think, with minimal research, but what does the ping > program do? I haven't been able to figure that one out, and I have used > numerous packett sniffers. > Things just look garbled. > Thanks for your help, > > > Tyler Littlefield. > Check out our website: > http://tysplace.the-leetest.net > check out my blog: > livejournal.com/~tylerrl > [my programs don't have bugs, just randomly added features] > [failure is not an option, it comes bundled with windows!] > > > _______________________________________________ > Speakup mailing list > Speakup@braille.uwo.ca > http://speech.braille.uwo.ca/mailman/listinfo/speakup ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: executing code under a child process and another tcp question ` Chris Norman @ ` tyler 0 siblings, 0 replies; 5+ messages in thread From: tyler @ UTC (permalink / raw) To: Chris Norman, Speakup is a screen review system for Linux. will do, thanks. Tyler Littlefield. Check out our website: http://tysplace.the-leetest.net check out my blog: livejournal.com/~tylerrl [my programs don't have bugs, just randomly added features] [failure is not an option, it comes bundled with windows!] ----- Original Message ----- From: "Chris Norman" <cnorman@rnibncw.ac.uk> To: "Speakup is a screen review system for Linux." <speakup@braille.uwo.ca> Sent: Tuesday, March 28, 2006 12:43 AM Subject: Re: executing code under a child process and another tcp question >I don't know about code execution, but if you want a really "worryingly" > good network sniffer, get NGREP. > > HTH, > > Chris Norman > <!-- chris.norman4@ntlworld.com --> > ----- Original Message ----- > From: "tyler" <compgeek13@gmail.com> > To: "Speakup is a screen review system for Linux." > <speakup@braille.uwo.ca> > Sent: Monday, March 27, 2006 6:00 PM > Subject: executing code under a child process and another tcp question > > >> Hello everyone,, >> Though these questions may bwe boardering on the relm of programming, I >> wasn't really sure where else to ask them, I am aware of the >> blindprogramming list, but don't like to sign up to lists with high >> traffic >> like that one, because sometimes its hard for me to check my email, and >> when >> I get back (just from being on the blindgamers list, and the three lists >> owned by the same organization as the programming@blindprogramming) after >> not reading email for like 4 days, I had over 700 emails. >> Anyway, I have a couple questions, >> I read up on fork, and found that it isn't just something used to eat >> your >> food with, but you can spawn other processes with it. >> But, my main idea was a pipe, I wanted to spawn a child process, and >> create >> a pipe to it, so I read up on pipes to. >> The only thing I have been able to find is how to get my process to >> execute >> shell commands, >> Do I have to stick to shell commands, or can I actually switch execution >> between child and parent. >> Also, how do I get the pid of the parent process? >> Last, I want to start playing with TCP. >> If I send in the raw mode, can I just send a struct as a packet? >> If so, that will only take me reading up on how packetts are formed (I >> know >> the basics) but not the exact ways, and then I can just create a struct >> to >> represent a packet, and send it to where ever I wish. I also as a little >> example wish to create a ping program, and a port scanner, I can do the >> port >> scanner fairly easy I think, with minimal research, but what does the >> ping >> program do? I haven't been able to figure that one out, and I have used >> numerous packett sniffers. >> Things just look garbled. >> Thanks for your help, >> >> >> Tyler Littlefield. >> Check out our website: >> http://tysplace.the-leetest.net >> check out my blog: >> livejournal.com/~tylerrl >> [my programs don't have bugs, just randomly added features] >> [failure is not an option, it comes bundled with windows!] >> >> >> _______________________________________________ >> Speakup mailing list >> Speakup@braille.uwo.ca >> http://speech.braille.uwo.ca/mailman/listinfo/speakup > > > _______________________________________________ > Speakup mailing list > Speakup@braille.uwo.ca > http://speech.braille.uwo.ca/mailman/listinfo/speakup ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: executing code under a child process and another tcp question executing code under a child process and another tcp question tyler ` Chris Norman @ ` Garry Turkington ` tyler 1 sibling, 1 reply; 5+ messages in thread From: Garry Turkington @ UTC (permalink / raw) To: Speakup is a screen review system for Linux. I haven't written multi-threaded code in C for years but here's a few vague pointers from memory. Calling fork() returns an integer, the status of that lets you know whether or not you're in the parent or child. A common way of working therefore is something like: int id = fork() ; if (id == something) { /* in child */ execl( <path-to-executable>...) ; /* error check here */ } else /* in parent */ So the parent carries on with the main code, the child executes another executable, script or whatever and that is the child process code. Obviously the child code can just be embedded in the same source file but unless its really trivial it becomes unwieldy. Pipes are pretty straightforward. Create a pipe, use dup2 to hook up the parent stdout to the child stdin and vice versa and you have a very crude but workable way of passing info back and forth. So, read up on fork(), execlp(), pipe() and dup2() and you should work it all out. One point though - C is a really unfriendly language to learn things like multithreaded or socket programming. If you want to learn the concepts (and with multi-threaded code it will take a very long time) as opposed to an immediate need to actually use it in C then I'd suggest doing your learning in another language. The difficulties of the material are great enough without getting caught around the axle of the particular language idiosyncracies. Regards, Garry -- Garry Turkington garry.turkington@gmail.com On Mon, 27 Mar 2006, tyler wrote: > Hello everyone,, > Though these questions may bwe boardering on the relm of programming, I > wasn't really sure where else to ask them, I am aware of the > blindprogramming list, but don't like to sign up to lists with high traffic > like that one, because sometimes its hard for me to check my email, and when > I get back (just from being on the blindgamers list, and the three lists > owned by the same organization as the programming@blindprogramming) after > not reading email for like 4 days, I had over 700 emails. > Anyway, I have a couple questions, > I read up on fork, and found that it isn't just something used to eat your > food with, but you can spawn other processes with it. > But, my main idea was a pipe, I wanted to spawn a child process, and create > a pipe to it, so I read up on pipes to. > The only thing I have been able to find is how to get my process to execute > shell commands, > Do I have to stick to shell commands, or can I actually switch execution > between child and parent. > Also, how do I get the pid of the parent process? > Last, I want to start playing with TCP. > If I send in the raw mode, can I just send a struct as a packet? > If so, that will only take me reading up on how packetts are formed (I know > the basics) but not the exact ways, and then I can just create a struct to > represent a packet, and send it to where ever I wish. I also as a little > example wish to create a ping program, and a port scanner, I can do the port > scanner fairly easy I think, with minimal research, but what does the ping > program do? I haven't been able to figure that one out, and I have used > numerous packett sniffers. > Things just look garbled. > Thanks for your help, > > > Tyler Littlefield. > Check out our website: > http://tysplace.the-leetest.net > check out my blog: > livejournal.com/~tylerrl > [my programs don't have bugs, just randomly added features] > [failure is not an option, it comes bundled with windows!] > > > _______________________________________________ > Speakup mailing list > Speakup@braille.uwo.ca > http://speech.braille.uwo.ca/mailman/listinfo/speakup > ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: executing code under a child process and another tcp question ` Garry Turkington @ ` tyler 0 siblings, 0 replies; 5+ messages in thread From: tyler @ UTC (permalink / raw) To: Speakup is a screen review system for Linux. will check those. Thanks, Tyler Littlefield. Check out our website: http://tysplace.the-leetest.net check out my blog: livejournal.com/~tylerrl [my programs don't have bugs, just randomly added features] [failure is not an option, it comes bundled with windows!] ----- Original Message ----- From: "Garry Turkington" <garry.turkington@acm.org> To: "Speakup is a screen review system for Linux." <speakup@braille.uwo.ca> Sent: Wednesday, March 29, 2006 2:24 PM Subject: Re: executing code under a child process and another tcp question > > I haven't written multi-threaded code in C for years but here's a few > vague pointers from memory. > > Calling fork() returns an integer, the status of that lets you know > whether or not you're in the parent or child. A common way of working > therefore is something like: > > int id = fork() ; > > if (id == something) > { > /* in child */ > > execl( <path-to-executable>...) ; > /* error check here */ > } > else > /* in parent */ > > So the parent carries on with the main code, the child executes another > executable, script or whatever and that is the child process code. > Obviously the child code can just be embedded in the same source file but > unless its really trivial it becomes unwieldy. > > Pipes are pretty straightforward. Create a pipe, use dup2 to hook up the > parent stdout to the child stdin and vice versa and you have a very crude > but workable way of passing info back and forth. > > So, read up on fork(), execlp(), pipe() and dup2() and you should work it > all out. > > One point though - C is a really unfriendly language to learn things like > multithreaded or socket programming. If you want to learn the concepts > (and with multi-threaded code it will take a very long time) as opposed to > an immediate need to actually use it in C then I'd suggest doing your > learning in another language. The difficulties of the material are great > enough without getting caught around the axle of the particular language > idiosyncracies. > > Regards, > Garry > > -- > Garry Turkington > garry.turkington@gmail.com > > On Mon, 27 Mar 2006, tyler wrote: > >> Hello everyone,, >> Though these questions may bwe boardering on the relm of programming, I >> wasn't really sure where else to ask them, I am aware of the >> blindprogramming list, but don't like to sign up to lists with high >> traffic >> like that one, because sometimes its hard for me to check my email, and >> when >> I get back (just from being on the blindgamers list, and the three lists >> owned by the same organization as the programming@blindprogramming) after >> not reading email for like 4 days, I had over 700 emails. >> Anyway, I have a couple questions, >> I read up on fork, and found that it isn't just something used to eat >> your >> food with, but you can spawn other processes with it. >> But, my main idea was a pipe, I wanted to spawn a child process, and >> create >> a pipe to it, so I read up on pipes to. >> The only thing I have been able to find is how to get my process to >> execute >> shell commands, >> Do I have to stick to shell commands, or can I actually switch execution >> between child and parent. >> Also, how do I get the pid of the parent process? >> Last, I want to start playing with TCP. >> If I send in the raw mode, can I just send a struct as a packet? >> If so, that will only take me reading up on how packetts are formed (I >> know >> the basics) but not the exact ways, and then I can just create a struct >> to >> represent a packet, and send it to where ever I wish. I also as a little >> example wish to create a ping program, and a port scanner, I can do the >> port >> scanner fairly easy I think, with minimal research, but what does the >> ping >> program do? I haven't been able to figure that one out, and I have used >> numerous packett sniffers. >> Things just look garbled. >> Thanks for your help, >> >> >> Tyler Littlefield. >> Check out our website: >> http://tysplace.the-leetest.net >> check out my blog: >> livejournal.com/~tylerrl >> [my programs don't have bugs, just randomly added features] >> [failure is not an option, it comes bundled with windows!] >> >> >> _______________________________________________ >> Speakup mailing list >> Speakup@braille.uwo.ca >> http://speech.braille.uwo.ca/mailman/listinfo/speakup >> > > _______________________________________________ > Speakup mailing list > Speakup@braille.uwo.ca > http://speech.braille.uwo.ca/mailman/listinfo/speakup ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~ UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- executing code under a child process and another tcp question tyler ` Chris Norman ` tyler ` Garry Turkington ` tyler
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).