Travel by air has become increasingly regulated in recent years, as terrorist threats and customs regulations have limited the items that can be transported by air, particularly within the passenger cabin. However, you are allowed to bring some types of food in your carry-on to assuage hunger during long flights.
Liquids and Gels
The U.S. Transportation and Safety Administration (TSA) allows liquids and gels only in individual containers less than 3.4 oz. (100mL), all of which must fit into one 1-quart resealable clear plastic bag. This also applies to liquid-like foods such as mashed potatoes, canned vegetables, and cream cheese.
The volume of food that you may bring onto airplanes depends on two limitations: carry-on space/allowance (as determined, for the most part, by individual airlines), and commercial value (as determined by customs regulations). Most airlines allow one or two carry-on items, but smaller flights may allow only one or none. Customs regulations dictate that food items with a commercial value over a certain amount (in the United States this is usually $800) are subject to duties and potential seizure.
Baby and Medical Supplies
Baby food, breast milk, and infant formula are not subject to the liquid and gels regulations. However, they must be declared and presented at airport security. Travelers with a medical condition or disability may also be exempt--for example, diabetics are allowed to bring glucose supplies, so long as these are declared at security.
All food must be wrapped or in a container in order to pass through the x-ray machine at security. Unpeeled fruits and some vegetables need not be wrapped unless they are cut (or bitten).
Airlines may restrict the food allowed in carry-on baggage. For example, some airlines do not allow alcohol in carry-on bags, and most do not allow such alcohol to be consumed en route.
Cakes and Pies
Cakes and pies are usually allowed in carry-on baggage. However, the TSA notes that these "may be subjected to additional screening" because they often resemble gels on x-ray.
Customs regulations regulate the transportation of food across international and state borders, regardless of whether such food is carried on or in checked baggage. For example, travelers are not allowed to bring citrus fruit into the United States. In some cases you may be able to consume such foods in flight; however, for countries such as Canada that have a U.S. pre-screening process, prohibited foods will likely be confiscated.