• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 10:55
CET 15:55
KST 23:55
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
ByuL: The Forgotten Master of ZvT30Behind the Blue - Team Liquid History Book19Clem wins HomeStory Cup 289HomeStory Cup 28 - Info & Preview13Rongyi Cup S3 - Preview & Info8
Community News
Weekly Cups (March 9-15): herO, Clem, ByuN win02026 KungFu Cup Announcement5BGE Stara Zagora 2026 cancelled12Blizzard Classic Cup - Tastosis announced as captains16Weekly Cups (March 2-8): ByuN overcomes PvT block4
StarCraft 2
General
Weekly Cups (March 9-15): herO, Clem, ByuN win Blizzard Classic Cup - Tastosis announced as captains GSL CK - New online series BGE Stara Zagora 2026 cancelled BGE Stara Zagora 2026 announced
Tourneys
2026 KungFu Cup Announcement [GSL CK] #2: Team Classic vs. Team Solar [GSL CK] #1: Team Maru vs. Team herO RSL Season 4 announced for March-April PIG STY FESTIVAL 7.0! (19 Feb - 1 Mar)
Strategy
Custom Maps
Publishing has been re-enabled! [Feb 24th 2026] Map Editor closed ?
External Content
The PondCast: SC2 News & Results Mutation # 517 Distant Threat Mutation # 516 Specter of Death Mutation # 515 Together Forever
Brood War
General
BGH Auto Balance -> http://bghmmr.eu/ ASL21 General Discussion Gypsy to Korea BSL 22 Map Contest — Submissions OPEN to March 10 Are you ready for ASL 21? Hype VIDEO
Tourneys
ASL Season 21 Qualifiers March 7-8 [Megathread] Daily Proleagues [BSL22] Open Qualifiers & Ladder Tours IPSL Spring 2026 is here!
Strategy
Simple Questions, Simple Answers Soma's 9 hatch build from ASL Game 2 Fighting Spirit mining rates Zealot bombing is no longer popular?
Other Games
General Games
Stormgate/Frost Giant Megathread Dawn of War IV Path of Exile Nintendo Switch Thread PC Games Sales Thread
Dota 2
Official 'what is Dota anymore' discussion The Story of Wings Gaming
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
Five o'clock TL Mafia Mafia Game Mode Feedback/Ideas Vanilla Mini Mafia TL Mafia Community Thread
Community
General
US Politics Mega-thread Mexico's Drug War Things Aren’t Peaceful in Palestine Russo-Ukrainian War Thread NASA and the Private Sector
Fan Clubs
The IdrA Fan Club
Media & Entertainment
[Manga] One Piece Movie Discussion! [Req][Books] Good Fantasy/SciFi books
Sports
2024 - 2026 Football Thread Tokyo Olympics 2021 Thread Formula 1 Discussion General nutrition recommendations Cricket [SPORT]
World Cup 2022
Tech Support
Laptop capable of using Photoshop Lightroom?
TL Community
The Automated Ban List
Blogs
Funny Nicknames
LUCKY_NOOB
Money Laundering In Video Ga…
TrAiDoS
Iranian anarchists: organize…
XenOsky
FS++
Kraekkling
Shocked by a laser…
Spydermine0240
Unintentional protectionism…
Uldridge
ASL S21 English Commentary…
namkraft
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1562 users

The Big Programming Thread - Page 267

Forum Index > General Forum
Post a Reply
Prev 1 265 266 267 268 269 1032 Next
Thread Rules
1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution.
2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20)
3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible.
4. Use [code] tags to format code blocks.
KurtistheTurtle
Profile Blog Joined December 2008
United States1966 Posts
March 10 2013 09:02 GMT
#5321
On March 10 2013 13:06 sob3k wrote:
Show nested quote +
On March 10 2013 12:34 CecilSunkure wrote:
On March 10 2013 12:31 sob3k wrote:
Here is my question guys:

I am very interested in learning how to design GUI's. I see just absolutely terrible GUI's in major products all the time and I really think I could contribute. I have very basic programming experience, but I'm ready to learn. I may seem silly but I really am passionate about really well designed GUI. It just makes such a huge difference when you don't have to fight a program you may use for hours a day, and I see such garbage running on massive products all the time that I just ache to be able to fix it.

What languages do you guys recommend? I'm interested in all kinds of GUI, games are often a great example of terrible UI that people are forced through, but I'm also totally up for all kinds of applications. I'm just looking for a starting spot.

Well I think wxWidgets would be something to try using. A lot of gui work is going to be done with middleware, and most work to be done in terms of designing GUIs will be done by usability experts. A usability expert won't write any code at all and only give feedback on the state of a project. So there's a pretty big separation between the jobs in large companies.

Smaller independent developers of games will of course design their own UI, but they won't be hiring someone to do it for them.

At Microsoft such a task would be up to the likes of a project manager, which again won't really be writing any code.


this is kind of what I was afraid of...So do you have any advice for how I could actually pursue getting into this field? It seems like If I could do the whole process and establish some sort of a portfolio it could get my ass in the door so to speak. how does one become a "usability expert", I mean from my point of view I just cringe on a daily basis seeing these awful design decisions. But I can't expect to just go into a company and say "look, your UI is a fucking disaster, pay me to fix it"....


1. Do it for free
2. Measure the results to see if your new designs were actually more usable
3. Pitch the proven benefits & testimonies of your services to other clients
“Reject your sense of injury and the injury itself disappears."
tec27
Profile Blog Joined June 2004
United States3702 Posts
March 10 2013 10:40 GMT
#5322
On March 10 2013 13:06 sob3k wrote:
Show nested quote +
On March 10 2013 12:34 CecilSunkure wrote:
On March 10 2013 12:31 sob3k wrote:
Here is my question guys:

I am very interested in learning how to design GUI's. I see just absolutely terrible GUI's in major products all the time and I really think I could contribute. I have very basic programming experience, but I'm ready to learn. I may seem silly but I really am passionate about really well designed GUI. It just makes such a huge difference when you don't have to fight a program you may use for hours a day, and I see such garbage running on massive products all the time that I just ache to be able to fix it.

What languages do you guys recommend? I'm interested in all kinds of GUI, games are often a great example of terrible UI that people are forced through, but I'm also totally up for all kinds of applications. I'm just looking for a starting spot.

Well I think wxWidgets would be something to try using. A lot of gui work is going to be done with middleware, and most work to be done in terms of designing GUIs will be done by usability experts. A usability expert won't write any code at all and only give feedback on the state of a project. So there's a pretty big separation between the jobs in large companies.

Smaller independent developers of games will of course design their own UI, but they won't be hiring someone to do it for them.

At Microsoft such a task would be up to the likes of a project manager, which again won't really be writing any code.


this is kind of what I was afraid of...So do you have any advice for how I could actually pursue getting into this field? It seems like If I could do the whole process and establish some sort of a portfolio it could get my ass in the door so to speak. how does one become a "usability expert", I mean from my point of view I just cringe on a daily basis seeing these awful design decisions. But I can't expect to just go into a company and say "look, your UI is a fucking disaster, pay me to fix it"....

HCI (Human-Computer Interaction) is a good field to look into for this. You'd wanna have skills in prototyping interfaces (there are a lot of toolkits around for doing this, differing depending on whether you're interested in mobile, web, or desktop applications). Most of these tools are going to focus on rapid development without a whole lot of programming (if any). I think if I was trying to convince a company that I could better their product, I would prototype out a better interface to their application to convince them, but there's a lot more to this sort of work than just what you think is best. You'll need knowledge of running usability studies (and being able to analyze the results) and I'd imagine that's pretty hard to develop without working under someone that already has a lot of these skills, unfortunately.
Can you jam with the console cowboys in cyberspace?
JonGalt
Profile Joined February 2013
Pootie too good!4331 Posts
March 10 2013 10:51 GMT
#5323
On March 09 2013 00:31 Yoshi- wrote:
Show nested quote +
On March 09 2013 00:16 JonGalt wrote:
On March 07 2013 18:50 disco wrote:
On March 07 2013 15:54 JonGalt wrote:
On March 07 2013 04:57 tofucake wrote:
do you have php installed and enabled?


I have php installed. I think I have it enabled, but I am unsure now.

I installed php5, mysql, and phphmyadmin through the terminal the other day. Then I made a dbconfig.php, register.php, login.php, members.php, logout.php, and integrated them with my login.html and register.html.

When I try to register a user through register.html, my browser (chromium) just downloads register.php instead of sending the data to the database. I did many searches and it seemed like I did not have the apache2 conf files correctly configured. After editing what was suggested, I still have the same problem.

And I don't think I have Xammp installed. If you need more information or I am unclear, let me know.


Did you install libapache2-mod-php5 and not just the php cli? (If you want to run php as a apache module that is, which I am assuming you do).

Using a package manager (apt-get) makes your life so much easier. It will automatically update the configuration files for you as well.


I do have this installed. The same problem persists and is rather annoying. Any ideas or suggestions? I am searching the web and trying to read up but still nothing.


http://www.php.net/manual/en/install.unix.apache2.php

See if steps 7 and 8 apply to your Config file from apache.


I will check this out when my computer is charged again, thanks!
LiquidLegends StaffWho is Jon Galt?
icystorage
Profile Blog Joined November 2008
Jollibee19350 Posts
March 10 2013 11:12 GMT
#5324
On March 10 2013 19:40 tec27 wrote:
Show nested quote +
On March 10 2013 13:06 sob3k wrote:
On March 10 2013 12:34 CecilSunkure wrote:
On March 10 2013 12:31 sob3k wrote:
Here is my question guys:

I am very interested in learning how to design GUI's. I see just absolutely terrible GUI's in major products all the time and I really think I could contribute. I have very basic programming experience, but I'm ready to learn. I may seem silly but I really am passionate about really well designed GUI. It just makes such a huge difference when you don't have to fight a program you may use for hours a day, and I see such garbage running on massive products all the time that I just ache to be able to fix it.

What languages do you guys recommend? I'm interested in all kinds of GUI, games are often a great example of terrible UI that people are forced through, but I'm also totally up for all kinds of applications. I'm just looking for a starting spot.

Well I think wxWidgets would be something to try using. A lot of gui work is going to be done with middleware, and most work to be done in terms of designing GUIs will be done by usability experts. A usability expert won't write any code at all and only give feedback on the state of a project. So there's a pretty big separation between the jobs in large companies.

Smaller independent developers of games will of course design their own UI, but they won't be hiring someone to do it for them.

At Microsoft such a task would be up to the likes of a project manager, which again won't really be writing any code.


this is kind of what I was afraid of...So do you have any advice for how I could actually pursue getting into this field? It seems like If I could do the whole process and establish some sort of a portfolio it could get my ass in the door so to speak. how does one become a "usability expert", I mean from my point of view I just cringe on a daily basis seeing these awful design decisions. But I can't expect to just go into a company and say "look, your UI is a fucking disaster, pay me to fix it"....

HCI (Human-Computer Interaction) is a good field to look into for this. You'd wanna have skills in prototyping interfaces (there are a lot of toolkits around for doing this, differing depending on whether you're interested in mobile, web, or desktop applications). Most of these tools are going to focus on rapid development without a whole lot of programming (if any). I think if I was trying to convince a company that I could better their product, I would prototype out a better interface to their application to convince them, but there's a lot more to this sort of work than just what you think is best. You'll need knowledge of running usability studies (and being able to analyze the results) and I'd imagine that's pretty hard to develop without working under someone that already has a lot of these skills, unfortunately.


i was about to post HCI but beat me to it. So i second this.
LiquidDota StaffAre you ready for a Miracle-? We are! The International 2017 Champions!
sob3k
Profile Blog Joined August 2009
United States7572 Posts
Last Edited: 2013-03-10 18:15:29
March 10 2013 18:10 GMT
#5325
So for this HCI and GUI design stuff do you have any specific recommendations on toolkits or languages I could start working on or looking into now?

Does anyone have any idea how I would get into contact with someone in this field, or at least a first step in finding one?

You guys seem to agree that If I could prototype an improvement and show it/propose it, that would be a good start. So any more specific advice on what I would need to learn in order to do that other than a university HCI program? Who even offers HCI programs?
In Hungry Hungry Hippos there are no such constraints—one can constantly attempt to collect marbles with one’s hippo, limited only by one’s hippo-levering capabilities.
icystorage
Profile Blog Joined November 2008
Jollibee19350 Posts
March 10 2013 23:04 GMT
#5326
you can try this

http://www.cs.cmu.edu/~bam/uicourse/special/
LiquidDota StaffAre you ready for a Miracle-? We are! The International 2017 Champions!
sob3k
Profile Blog Joined August 2009
United States7572 Posts
March 12 2013 00:21 GMT
#5327
So nobody has any idea of a starting place for UI design? I feel like there has to be some language I could pick up to get me creating something...its never a waste of time to learn a common language. I'm sick in my mothers apartment for the next 8 weeks and I really want to make some life progress on something.
In Hungry Hungry Hippos there are no such constraints—one can constantly attempt to collect marbles with one’s hippo, limited only by one’s hippo-levering capabilities.
Beamer
Profile Joined March 2010
United States242 Posts
Last Edited: 2013-03-12 00:30:08
March 12 2013 00:29 GMT
#5328
I'm trying to understand piping, but I'm having some trouble with it. My program is supposed to run a linux command that utilizes pipes, and I found some code that does this correctly. However, I don't understand what some of it does.

+ Show Spoiler [Working Code] +

#include <unistd.h>
#include <sys/wait.h>

// This program runs the following command: ls -ltr | wc -l

int main()
{
pid_t pid1;
char *argvv[2][3] = { { "ls", "-ltr", 0}, { "wc", "-l", 0 } }; // commands to run
int status;

int fd[2];
pipe(fd);
pid1 = fork();

if(pid1 == 0) /* Child executing */
{
close(fd[0]); // Child will not be reading, close this pipe
close(1);
dup(fd[1]);
close(fd[1]);
execvp(argvv[0][0], argvv[0]); // Run the command
}
else /* Parent executing */
{
wait(&status); // Wait until child is finished running
close(fd[1]); // Parent will not be writing, close this pipe
close(0);
dup(fd[0]);
close(fd[0]);
execvp(argvv[1][0], argvv[1]); // Run the command
}

return 0;
}




In particular, I don't understand what the dup function does, and I don't know what the uncommented close functions are for. Nevertheless, I tried to work off of this example to implement a program that runs a command with 2 pipes, but it's not working correctly:

+ Show Spoiler [Not working Code] +

#include <unistd.h>
#include <sys/wait.h>

// This program runs the following command: ls -ltr | head | wc -l

int main()
{
int pid;
char *argvv[3][3] = { { "ls", "-ltr", 0}, {"head", 0, 0 }, { "wc", "-l", 0 } }; // commands to run
int status;

int pipe1[2];
int pipe2[2];
pipe(pipe1);
pipe(pipe2);

pid = fork();
if(pid == 0) /* Child executing */
{
pid = fork();
if(pid == 0) /* Child's child executing */
{
close(pipe1[0]); // Child will not be reading, close this pipe
close(1);
dup(pipe1[1]);
close(pipe1[1]);
execvp(argvv[0][0], argvv[0]); // Run the command
}
else
{
wait(&status); // Wait until child is finished running
close(pipe1[1]); // Child will not be reading, close this pipe
close(0);
dup(pipe1[0]);
close(pipe1[0]);

close(pipe2[0]); // Child will not be reading, close this pipe
close(1);
dup(pipe2[1]);
close(pipe2[1]);
execvp(argvv[1][0], argvv[1]); // Run the command
}
}
else /* Parent executing */
{
wait(&status); // Wait until child is finished running
close(pipe2[1]); // Parent will not be writing, close this pipe
close(0);
dup(pipe2[0]);
close(pipe2[0]);
execvp(argvv[2][0], argvv[2]); // Run the command
}

return 0;
}



Hopefully someone can give me some insights into pipes that will help me understand how to work with them.
fabiano
Profile Blog Joined August 2009
Brazil4644 Posts
March 12 2013 00:35 GMT
#5329
HCI is just common sense...

Yes, it's amazing how often you find software with horribly made interfaces (Bnet 2.0 is a great example), but still... it all comes down to common sense.

I like to believe that whenever I see a badly designed interface it was just the team who neglected UI in order to prioritize more important functionalities on a tight schedule.
"When the geyser died, a probe came out" - SirJolt
sob3k
Profile Blog Joined August 2009
United States7572 Posts
March 12 2013 00:57 GMT
#5330
On March 12 2013 09:35 fabiano wrote:
HCI is just common sense...

Yes, it's amazing how often you find software with horribly made interfaces (Bnet 2.0 is a great example), but still... it all comes down to common sense.

I like to believe that whenever I see a badly designed interface it was just the team who neglected UI in order to prioritize more important functionalities on a tight schedule.


right, but obviously I cant just walk into a company with a sketch pad, tell them their UI is trash hire me to tell your programmers what to do, with nothing to show for it.

In Hungry Hungry Hippos there are no such constraints—one can constantly attempt to collect marbles with one’s hippo, limited only by one’s hippo-levering capabilities.
fabiano
Profile Blog Joined August 2009
Brazil4644 Posts
March 12 2013 01:52 GMT
#5331
Try QT if you want to develop UI.
"When the geyser died, a probe came out" - SirJolt
CecilSunkure
Profile Blog Joined May 2010
United States2829 Posts
Last Edited: 2013-03-12 03:40:44
March 12 2013 03:40 GMT
#5332
On March 12 2013 09:29 Beamer wrote:
I'm trying to understand piping, but I'm having some trouble with it. My program is supposed to run a linux command that utilizes pipes, and I found some code that does this correctly. However, I don't understand what some of it does.

+ Show Spoiler [Working Code] +

#include <unistd.h>
#include <sys/wait.h>

// This program runs the following command: ls -ltr | wc -l

int main()
{
pid_t pid1;
char *argvv[2][3] = { { "ls", "-ltr", 0}, { "wc", "-l", 0 } }; // commands to run
int status;

int fd[2];
pipe(fd);
pid1 = fork();

if(pid1 == 0) /* Child executing */
{
close(fd[0]; // Child will not be reading, close this pipe
close(1);
dup(fd[1];
close(fd[1];
execvp(argvv[0][0], argvv[0]; // Run the command
}
else /* Parent executing */
{
wait(&status); // Wait until child is finished running
close(fd[1]; // Parent will not be writing, close this pipe
close(0);
dup(fd[0];
close(fd[0];
execvp(argvv[1][0], argvv[1]; // Run the command
}

return 0;
}




In particular, I don't understand what the dup function does, and I don't know what the uncommented close functions are for. Nevertheless, I tried to work off of this example to implement a program that runs a command with 2 pipes, but it's not working correctly:

+ Show Spoiler [Not working Code] +

#include <unistd.h>
#include <sys/wait.h>

// This program runs the following command: ls -ltr | head | wc -l

int main()
{
int pid;
char *argvv[3][3] = { { "ls", "-ltr", 0}, {"head", 0, 0 }, { "wc", "-l", 0 } }; // commands to run
int status;

int pipe1[2];
int pipe2[2];
pipe(pipe1);
pipe(pipe2);

pid = fork();
if(pid == 0) /* Child executing */
{
pid = fork();
if(pid == 0) /* Child's child executing */
{
close(pipe1[0]; // Child will not be reading, close this pipe
close(1);
dup(pipe1[1];
close(pipe1[1];
execvp(argvv[0][0], argvv[0]; // Run the command
}
else
{
wait(&status); // Wait until child is finished running
close(pipe1[1]; // Child will not be reading, close this pipe
close(0);
dup(pipe1[0];
close(pipe1[0];

close(pipe2[0]; // Child will not be reading, close this pipe
close(1);
dup(pipe2[1];
close(pipe2[1];
execvp(argvv[1][0], argvv[1]; // Run the command
}
}
else /* Parent executing */
{
wait(&status); // Wait until child is finished running
close(pipe2[1]; // Parent will not be writing, close this pipe
close(0);
dup(pipe2[0];
close(pipe2[0];
execvp(argvv[2][0], argvv[2]; // Run the command
}

return 0;
}



Hopefully someone can give me some insights into pipes that will help me understand how to work with them.


Pipes are simple. When you run a program it outputs text. This text can be put into a file like so:
name.exe > out.txt


Then you can use that output as input for another program:
other.exe < out.txt


However you can speed things up tremendously by re-routing stdout for the first program, to go into stdin for the second program. This can be quite a difficult thing to do on your own, but luckily the OS does it for you:
name.exe | other.exe


Here the output from name.exe is going to be sent to stdout, and the operating system will feed name.exe's stdout directly into other.exe's stdin. Neither program will have any knowledge of this rerouting, as the rerouting is done within the OS layer.

You can feed output of programs into other programs as input and form long chains to do various types of actions:
name.exe | other.exe | grep | blahblah > out.txt


Above, output goes from name.exe into other.exe, which then gets piped into grep (to perform some regex or something), then pipe that output into blahlbah, which ouputs into out.txt.

The idea is to use separate executable altogether to perform some common task. This is powerful because each program can be highly specialized to perform a very specific task, and simply be "plugged into" some command line for versatile use.
tec27
Profile Blog Joined June 2004
United States3702 Posts
Last Edited: 2013-03-12 06:09:30
March 12 2013 06:03 GMT
#5333
On March 12 2013 12:40 CecilSunkure wrote:
Show nested quote +
On March 12 2013 09:29 Beamer wrote:
I'm trying to understand piping, but I'm having some trouble with it. My program is supposed to run a linux command that utilizes pipes, and I found some code that does this correctly. However, I don't understand what some of it does.

+ Show Spoiler [Working Code] +

#include <unistd.h>
#include <sys/wait.h>

// This program runs the following command: ls -ltr | wc -l

int main()
{
pid_t pid1;
char *argvv[2][3] = { { "ls", "-ltr", 0}, { "wc", "-l", 0 } }; // commands to run
int status;

int fd[2];
pipe(fd);
pid1 = fork();

if(pid1 == 0) /* Child executing */
{
close(fd[0]; // Child will not be reading, close this pipe
close(1);
dup(fd[1];
close(fd[1];
execvp(argvv[0][0], argvv[0]; // Run the command
}
else /* Parent executing */
{
wait(&status); // Wait until child is finished running
close(fd[1]; // Parent will not be writing, close this pipe
close(0);
dup(fd[0];
close(fd[0];
execvp(argvv[1][0], argvv[1]; // Run the command
}

return 0;
}




In particular, I don't understand what the dup function does, and I don't know what the uncommented close functions are for. Nevertheless, I tried to work off of this example to implement a program that runs a command with 2 pipes, but it's not working correctly:

+ Show Spoiler [Not working Code] +

#include <unistd.h>
#include <sys/wait.h>

// This program runs the following command: ls -ltr | head | wc -l

int main()
{
int pid;
char *argvv[3][3] = { { "ls", "-ltr", 0}, {"head", 0, 0 }, { "wc", "-l", 0 } }; // commands to run
int status;

int pipe1[2];
int pipe2[2];
pipe(pipe1);
pipe(pipe2);

pid = fork();
if(pid == 0) /* Child executing */
{
pid = fork();
if(pid == 0) /* Child's child executing */
{
close(pipe1[0]; // Child will not be reading, close this pipe
close(1);
dup(pipe1[1];
close(pipe1[1];
execvp(argvv[0][0], argvv[0]; // Run the command
}
else
{
wait(&status); // Wait until child is finished running
close(pipe1[1]; // Child will not be reading, close this pipe
close(0);
dup(pipe1[0];
close(pipe1[0];

close(pipe2[0]; // Child will not be reading, close this pipe
close(1);
dup(pipe2[1];
close(pipe2[1];
execvp(argvv[1][0], argvv[1]; // Run the command
}
}
else /* Parent executing */
{
wait(&status); // Wait until child is finished running
close(pipe2[1]; // Parent will not be writing, close this pipe
close(0);
dup(pipe2[0];
close(pipe2[0];
execvp(argvv[2][0], argvv[2]; // Run the command
}

return 0;
}



Hopefully someone can give me some insights into pipes that will help me understand how to work with them.


Pipes are simple. When you run a program it outputs text. This text can be put into a file like so:
name.exe > out.txt


Then you can use that output as input for another program:
other.exe < out.txt


However you can speed things up tremendously by re-routing stdout for the first program, to go into stdin for the second program. This can be quite a difficult thing to do on your own, but luckily the OS does it for you:
name.exe | other.exe


Here the output from name.exe is going to be sent to stdout, and the operating system will feed name.exe's stdout directly into other.exe's stdin. Neither program will have any knowledge of this rerouting, as the rerouting is done within the OS layer.

You can feed output of programs into other programs as input and form long chains to do various types of actions:
name.exe | other.exe | grep | blahblah > out.txt


Above, output goes from name.exe into other.exe, which then gets piped into grep (to perform some regex or something), then pipe that output into blahlbah, which ouputs into out.txt.

The idea is to use separate executable altogether to perform some common task. This is powerful because each program can be highly specialized to perform a very specific task, and simply be "plugged into" some command line for versatile use.

That's a nice explanation and all, but that's not at all what Beamer was asking. He's asking how to implement piping himself, and what you basically told him was "here's how you use pipes if they were already implemented!"

Anyway Beamer, I'll try to explain. Firstly, if you ever don't understand what a standard C function does, they're all basically in man (so you can just type like `man dup` in a shell and get a nice reference page (or find them online: http://linux.die.net/man/2/dup). Sometimes these will collide with other man pages (like for shell functions), so you can specify a section for them. Pretty much all of the functions dealing with this sort of stuff will be in section 2 (e.g. `man 2 dup`). Anyway, now that you know where to find future details on stuff, onto the explanation!

I'll just add comments to the original working code, since I think that will be a bit simpler to read:

Also available as a gist if you'd prefer to read it syntax highlighted: https://gist.github.com/tec27/0c928496c846c5c9856b
+ Show Spoiler [Commented code] +
#include <unistd.h>
#include <sys/wait.h>

// This program runs the following command: ls -ltr | wc -l

int main()
{
// this variable will store the pid of the currently executing process, more on this later
pid_t pid1;
// these are your program arguments (you could actually pass these into main instead of creating
// them here)
char *argvv[2][3] = { { "ls", "-ltr", 0}, { "wc", "-l", 0 } }; // commands to run
// this variable will be used to store the result code of the child process
int status;

// this is used to store our endpoints for the pipe
int fd[2];
// this fills fd with 2 file descriptors, fd[0] is the read end and fd[1] is the write end.
// any data you write to fd[1] can be read at fd[0]
pipe(fd);
// this causes a new process to be created that is a copy of the current process. This new
// process receives the same file descriptors as the currently running process, and begins its
// execution at the same point we are currently at.
pid1 = fork();

// since the child process begins its execution at the same point, we need to check whether we
// are in the child process or the parent process in order to decide what to do. fork() returns
// different pid results in each process, which allows us to check this with the following if
// statement:
if(pid1 == 0) /* Child executing */
{
// fd[0], as you'll recall, is the read end of our pipe. since this process will be executing
// the first command in our chain (ls -ltr), it has no need for reading. Thus, we can safely
// close that file descriptor in our pipe-created array
close(fd[0]); // Child will not be reading, close this pipe
// With this process, we want to pipe all of our output to the next command in the chain
// (wc -l). This means we don't want to send the output to STDOUT (the normal destination).
// Because of this, we should close STDOUT (which at process start will be at index 1 of the
// file descriptor table).
close(1);
// Now we need to replace STDOUT with our actual destination (the pipe write end). dup() will
// copy the given file descriptor into the lowest available position in the file descriptor
// table. Since we just opened up position 1 (STDOUT), this call will copy our write end of
// the pipe into stdout.
dup(fd[1]);
// Now that we have a copy of fd[1] in the actual file descriptor table, we no longer need it
// open in our pipe-created array, so we close it to clean up.
close(fd[1]);
// This will run the given command with the given arguments in the current process (meaning
// that it uses all the file descriptors we setup). Since we set the STDOUT position to our
// pipe instead of the standard file descriptor, anything this program outputs will go to
// our pipe.
execvp(argvv[0][0], argvv[0]); // Run the command
}
else /* Parent executing */
{
// Keep in mind that anything in this else will be running in a separate process from anything
// executing in the if above! This runs in the original (parent) process, and has its own
// variables, file descriptors, etc. (although they start from the same initialization point).

// First, we wait for the child process to finish executing. We don't want to start the next
// command in the chain until the output is completely in the pipe (although you could; this
// is how this particular implementation chose to do it).
wait(&status); // Wait until child is finished running
// Since we are going to be running the final command in the pipe, any ouput we have will go
// to the regular destination (STDOUT). As such, we have no need for the write end of the
// pipe-created array.
close(fd[1]); // Parent will not be writing, close this pipe
// The process we will be executing will be reading data from the pipe (the previous process's
// output) instead of from the normal location (STDIN). Because of this, we need to replace
// STDIN with the pipe's read end. First we close STDIN...
close(0);
// Then we dup our read end into its position in the table, as above.
dup(fd[0]);
// Again, we have copied this file descriptor, so we no longer need to keep the original open.
close(fd[0]);
// Execute the `wc -l` command. It uses the file descriptors we setup and thus reads from the
// pipe instead of stdin.
execvp(argvv[1][0], argvv[1]); // Run the command
}

// this will never actually be reached because the current process image is replaced by execvp,
// but your compiler will probably complain otherwise! (oh, and execvp can return if it errors,
// like if it can't find the thing you're trying to execute).
return 0;
}


Hopefully that helps you understand this stuff a bit better so you can get your code working (although it does look mostly correct to me from a glance). I'd encourage you to, instead of approaching this as a copy-paste job, try to generalize it to N piped processes. You'll probably have to do it as a later part of whatever course this is for anyway
Can you jam with the console cowboys in cyberspace?
obesechicken13
Profile Blog Joined July 2008
United States10467 Posts
March 12 2013 14:37 GMT
#5334
On March 12 2013 15:03 tec27 wrote:
Show nested quote +
On March 12 2013 12:40 CecilSunkure wrote:
On March 12 2013 09:29 Beamer wrote:
I'm trying to understand piping, but I'm having some trouble with it. My program is supposed to run a linux command that utilizes pipes, and I found some code that does this correctly. However, I don't understand what some of it does.

+ Show Spoiler [Working Code] +

#include <unistd.h>
#include <sys/wait.h>

// This program runs the following command: ls -ltr | wc -l

int main()
{
pid_t pid1;
char *argvv[2][3] = { { "ls", "-ltr", 0}, { "wc", "-l", 0 } }; // commands to run
int status;

int fd[2];
pipe(fd);
pid1 = fork();

if(pid1 == 0) /* Child executing */
{
close(fd[0]; // Child will not be reading, close this pipe
close(1);
dup(fd[1];
close(fd[1];
execvp(argvv[0][0], argvv[0]; // Run the command
}
else /* Parent executing */
{
wait(&status); // Wait until child is finished running
close(fd[1]; // Parent will not be writing, close this pipe
close(0);
dup(fd[0];
close(fd[0];
execvp(argvv[1][0], argvv[1]; // Run the command
}

return 0;
}




In particular, I don't understand what the dup function does, and I don't know what the uncommented close functions are for. Nevertheless, I tried to work off of this example to implement a program that runs a command with 2 pipes, but it's not working correctly:

+ Show Spoiler [Not working Code] +

#include <unistd.h>
#include <sys/wait.h>

// This program runs the following command: ls -ltr | head | wc -l

int main()
{
int pid;
char *argvv[3][3] = { { "ls", "-ltr", 0}, {"head", 0, 0 }, { "wc", "-l", 0 } }; // commands to run
int status;

int pipe1[2];
int pipe2[2];
pipe(pipe1);
pipe(pipe2);

pid = fork();
if(pid == 0) /* Child executing */
{
pid = fork();
if(pid == 0) /* Child's child executing */
{
close(pipe1[0]; // Child will not be reading, close this pipe
close(1);
dup(pipe1[1];
close(pipe1[1];
execvp(argvv[0][0], argvv[0]; // Run the command
}
else
{
wait(&status); // Wait until child is finished running
close(pipe1[1]; // Child will not be reading, close this pipe
close(0);
dup(pipe1[0];
close(pipe1[0];

close(pipe2[0]; // Child will not be reading, close this pipe
close(1);
dup(pipe2[1];
close(pipe2[1];
execvp(argvv[1][0], argvv[1]; // Run the command
}
}
else /* Parent executing */
{
wait(&status); // Wait until child is finished running
close(pipe2[1]; // Parent will not be writing, close this pipe
close(0);
dup(pipe2[0];
close(pipe2[0];
execvp(argvv[2][0], argvv[2]; // Run the command
}

return 0;
}



Hopefully someone can give me some insights into pipes that will help me understand how to work with them.


Pipes are simple. When you run a program it outputs text. This text can be put into a file like so:
name.exe > out.txt


Then you can use that output as input for another program:
other.exe < out.txt


However you can speed things up tremendously by re-routing stdout for the first program, to go into stdin for the second program. This can be quite a difficult thing to do on your own, but luckily the OS does it for you:
name.exe | other.exe


Here the output from name.exe is going to be sent to stdout, and the operating system will feed name.exe's stdout directly into other.exe's stdin. Neither program will have any knowledge of this rerouting, as the rerouting is done within the OS layer.

You can feed output of programs into other programs as input and form long chains to do various types of actions:
name.exe | other.exe | grep | blahblah > out.txt


Above, output goes from name.exe into other.exe, which then gets piped into grep (to perform some regex or something), then pipe that output into blahlbah, which ouputs into out.txt.

The idea is to use separate executable altogether to perform some common task. This is powerful because each program can be highly specialized to perform a very specific task, and simply be "plugged into" some command line for versatile use.

That's a nice explanation and all, but that's not at all what Beamer was asking. He's asking how to implement piping himself, and what you basically told him was "here's how you use pipes if they were already implemented!"

Anyway Beamer, I'll try to explain. Firstly, if you ever don't understand what a standard C function does, they're all basically in man (so you can just type like `man dup` in a shell and get a nice reference page (or find them online: http://linux.die.net/man/2/dup). Sometimes these will collide with other man pages (like for shell functions), so you can specify a section for them. Pretty much all of the functions dealing with this sort of stuff will be in section 2 (e.g. `man 2 dup`). Anyway, now that you know where to find future details on stuff, onto the explanation!

I'll just add comments to the original working code, since I think that will be a bit simpler to read:

Also available as a gist if you'd prefer to read it syntax highlighted: https://gist.github.com/tec27/0c928496c846c5c9856b
+ Show Spoiler [Commented code] +
#include <unistd.h>
#include <sys/wait.h>

// This program runs the following command: ls -ltr | wc -l

int main()
{
// this variable will store the pid of the currently executing process, more on this later
pid_t pid1;
// these are your program arguments (you could actually pass these into main instead of creating
// them here)
char *argvv[2][3] = { { "ls", "-ltr", 0}, { "wc", "-l", 0 } }; // commands to run
// this variable will be used to store the result code of the child process
int status;

// this is used to store our endpoints for the pipe
int fd[2];
// this fills fd with 2 file descriptors, fd[0] is the read end and fd[1] is the write end.
// any data you write to fd[1] can be read at fd[0]
pipe(fd);
// this causes a new process to be created that is a copy of the current process. This new
// process receives the same file descriptors as the currently running process, and begins its
// execution at the same point we are currently at.
pid1 = fork();

// since the child process begins its execution at the same point, we need to check whether we
// are in the child process or the parent process in order to decide what to do. fork() returns
// different pid results in each process, which allows us to check this with the following if
// statement:
if(pid1 == 0) /* Child executing */
{
// fd[0], as you'll recall, is the read end of our pipe. since this process will be executing
// the first command in our chain (ls -ltr), it has no need for reading. Thus, we can safely
// close that file descriptor in our pipe-created array
close(fd[0]; // Child will not be reading, close this pipe
// With this process, we want to pipe all of our output to the next command in the chain
// (wc -l). This means we don't want to send the output to STDOUT (the normal destination).
// Because of this, we should close STDOUT (which at process start will be at index 1 of the
// file descriptor table).
close(1);
// Now we need to replace STDOUT with our actual destination (the pipe write end). dup() will
// copy the given file descriptor into the lowest available position in the file descriptor
// table. Since we just opened up position 1 (STDOUT), this call will copy our write end of
// the pipe into stdout.
dup(fd[1];
// Now that we have a copy of fd[1] in the actual file descriptor table, we no longer need it
// open in our pipe-created array, so we close it to clean up.
close(fd[1];
// This will run the given command with the given arguments in the current process (meaning
// that it uses all the file descriptors we setup). Since we set the STDOUT position to our
// pipe instead of the standard file descriptor, anything this program outputs will go to
// our pipe.
execvp(argvv[0][0], argvv[0]; // Run the command
}
else /* Parent executing */
{
// Keep in mind that anything in this else will be running in a separate process from anything
// executing in the if above! This runs in the original (parent) process, and has its own
// variables, file descriptors, etc. (although they start from the same initialization point).

// First, we wait for the child process to finish executing. We don't want to start the next
// command in the chain until the output is completely in the pipe (although you could; this
// is how this particular implementation chose to do it).
wait(&status); // Wait until child is finished running
// Since we are going to be running the final command in the pipe, any ouput we have will go
// to the regular destination (STDOUT). As such, we have no need for the write end of the
// pipe-created array.
close(fd[1]; // Parent will not be writing, close this pipe
// The process we will be executing will be reading data from the pipe (the previous process's
// output) instead of from the normal location (STDIN). Because of this, we need to replace
// STDIN with the pipe's read end. First we close STDIN...
close(0);
// Then we dup our read end into its position in the table, as above.
dup(fd[0];
// Again, we have copied this file descriptor, so we no longer need to keep the original open.
close(fd[0];
// Execute the `wc -l` command. It uses the file descriptors we setup and thus reads from the
// pipe instead of stdin.
execvp(argvv[1][0], argvv[1]; // Run the command
}

// this will never actually be reached because the current process image is replaced by execvp,
// but your compiler will probably complain otherwise! (oh, and execvp can return if it errors,
// like if it can't find the thing you're trying to execute).
return 0;
}


Hopefully that helps you understand this stuff a bit better so you can get your code working (although it does look mostly correct to me from a glance). I'd encourage you to, instead of approaching this as a copy-paste job, try to generalize it to N piped processes. You'll probably have to do it as a later part of whatever course this is for anyway

Yes, I was thinking the same thing. If beamer wanted to just use piping in bash it would have been easy to google it. But to write it is different.
I think in our modern age technology has evolved to become more addictive. The things that don't give us pleasure aren't used as much. Work was never meant to be fun, but doing it makes us happier in the long run.
KaiserJohan
Profile Joined May 2010
Sweden1808 Posts
March 12 2013 15:19 GMT
#5335
On March 12 2013 09:21 sob3k wrote:
So nobody has any idea of a starting place for UI design? I feel like there has to be some language I could pick up to get me creating something...its never a waste of time to learn a common language. I'm sick in my mothers apartment for the next 8 weeks and I really want to make some life progress on something.


Download visual studio 2010 express (its free) and use C#. Google around for some example C# project - it easily ties together code with drag-and-drop GUI creation tools.
England will fight to the last American
2Pacalypse-
Profile Joined October 2006
Croatia9530 Posts
March 12 2013 17:16 GMT
#5336
On March 12 2013 09:21 sob3k wrote:
So nobody has any idea of a starting place for UI design? I feel like there has to be some language I could pick up to get me creating something...its never a waste of time to learn a common language. I'm sick in my mothers apartment for the next 8 weeks and I really want to make some life progress on something.

If your priority is just UI design and not the actual programming, Microsoft Expression Blend is a pretty fun tool to play with.
Moderator"We're a community of geniuses because we've found how to extract 95% of the feeling of doing something amazing without actually doing anything." - Chill
ragz_gt
Profile Blog Joined April 2012
9172 Posts
Last Edited: 2013-03-12 17:27:15
March 12 2013 17:21 GMT
#5337
Does anyone know if there is a JUnit contrib that allow customizable test execution order?

I know the test dependency is bad blah blah blah, but it's really a pain for Selenium testing when navigation fails at an early level.

(I could switch to TestNG but that's sort of a last resort)
I'm not an otaku, I'm a specialist.
obesechicken13
Profile Blog Joined July 2008
United States10467 Posts
Last Edited: 2013-03-12 18:08:26
March 12 2013 18:08 GMT
#5338
On March 13 2013 02:21 ragz_gt wrote:
Does anyone know if there is a JUnit contrib that allow customizable test execution order?

I know the test dependency is bad blah blah blah, but it's really a pain for Selenium testing when navigation fails at an early level.

(I could switch to TestNG but that's sort of a last resort)

Yeah we use testng where I work.
I think in our modern age technology has evolved to become more addictive. The things that don't give us pleasure aren't used as much. Work was never meant to be fun, but doing it makes us happier in the long run.
nunez
Profile Blog Joined February 2011
Norway4003 Posts
March 12 2013 18:26 GMT
#5339
cheers tec27!
conspired against by a confederacy of dunces.
Frigo
Profile Joined August 2009
Hungary1023 Posts
March 12 2013 22:00 GMT
#5340
On March 13 2013 02:21 ragz_gt wrote:
Does anyone know if there is a JUnit contrib that allow customizable test execution order?

I remember such a feature in a newer JUnit release. It can at least randomize orders I believe, not sure about a user-defined order though.
Can tell you more details tomorrow when I have access to work mail.
http://www.fimfiction.net/user/Treasure_Chest
Prev 1 265 266 267 268 269 1032 Next
Please log in or register to reply.
Live Events Refresh
Wardi Open
12:00
#78
WardiTV1105
Rex127
IntoTheiNu 9
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Rex 122
RushiSC 38
StarCraft: Brood War
Horang2 8698
Sea 2662
Soma 931
Mini 663
Light 600
EffOrt 535
ZerO 470
Stork 433
Snow 368
ggaemo 237
[ Show more ]
Rush 213
hero 160
Killer 150
Mind 76
PianO 63
Sea.KH 61
sorry 60
Aegong 58
sSak 49
NotJumperer 44
Barracks 40
[sc1f]eonzerg 39
Shinee 31
GoRush 18
IntoTheRainbow 17
scan(afreeca) 15
Noble 11
Terrorterran 11
SilentControl 11
soO 9
ivOry 8
Rock 6
Britney 1
Dota 2
qojqva3459
League of Legends
JimRising 318
Counter-Strike
fl0m774
markeloff181
byalli58
adren_tv1
Super Smash Bros
Mew2King83
Heroes of the Storm
crisheroes331
Other Games
singsing2651
B2W.Neo1199
hiko744
Lowko396
Hui .225
Fuzer 198
XaKoH 136
QueenE74
ArmadaUGS60
ZerO(Twitch)20
Trikslyr2
Organizations
Dota 2
PGL Dota 2 - Main Stream614
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 13 non-featured ]
StarCraft 2
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Doublelift2644
• Jankos1671
• TFBlade403
Upcoming Events
Monday Night Weeklies
2h 5m
WardiTV Team League
21h 5m
PiGosaur Cup
1d 9h
Kung Fu Cup
1d 20h
OSC
2 days
The PondCast
2 days
KCM Race Survival
2 days
WardiTV Team League
2 days
Replay Cast
3 days
KCM Race Survival
3 days
[ Show More ]
WardiTV Team League
3 days
Korean StarCraft League
4 days
RSL Revival
4 days
Maru vs Zoun
Cure vs ByuN
uThermal 2v2 Circuit
5 days
BSL
5 days
RSL Revival
5 days
herO vs MaxPax
Rogue vs TriGGeR
BSL
6 days
Replay Cast
6 days
Replay Cast
6 days
Afreeca Starleague
6 days
Sharp vs Scan
Rain vs Mong
Wardi Open
6 days
Liquipedia Results

Completed

Proleague 2026-03-15
WardiTV Winter 2026
Underdog Cup #3

Ongoing

KCM Race Survival 2026 Season 1
Jeongseon Sooper Cup
BSL Season 22
CSL Elite League 2026
RSL Revival: Season 4
Nations Cup 2026
ESL Pro League S23 Finals
ESL Pro League S23 Stage 1&2
PGL Cluj-Napoca 2026
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter Qual

Upcoming

ASL Season 21
Acropolis #4 - TS6
2026 Changsha Offline CUP
Acropolis #4
IPSL Spring 2026
BSL 22 Non-Korean Championship
CSLAN 4
Kung Fu Cup 2026 Grand Finals
HSC XXIX
uThermal 2v2 2026 Main Event
NationLESS Cup
Stake Ranked Episode 2
CS Asia Championships 2026
Asian Champions League 2026
IEM Atlanta 2026
PGL Astana 2026
BLAST Rivals Spring 2026
CCT Season 3 Global Finals
IEM Rio 2026
PGL Bucharest 2026
Stake Ranked Episode 1
BLAST Open Spring 2026
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2026 TLnet. All Rights Reserved.