小编Bis*_*ker的帖子

为什么在fork之后关闭文件描述符会影响子进程?

我想通过按钮单击一个在linux中运行程序,因此我编写了一个函数execute:

void execute(const char* program_call, const char* param )
{
    pid_t child = vfork();

    if(child == 0) // child process
    {
        int child_pid = getpid();

        char *args[2]; // arguments for exec
        args[0] = (char*)program_call; // first argument is program_call
        args[1] = (char*)param;

        // close all opened file descriptors:
        const char* prefix = "/proc/";
        const char* suffix = "/fd/";
        char child_proc_dir[16]; 
        sprintf(child_proc_dir,"%s%d%s",prefix,child_pid, suffix);

        DIR *dir;
        struct dirent *ent;

        if ((dir = opendir (child_proc_dir)) != NULL) {
            // get files …
Run Code Online (Sandbox Code Playgroud)

c linux fork file-descriptor exec

5
推荐指数
1
解决办法
9146
查看次数

尝试和后缀树实现

我研究过Tries和Suffix Trees,并希望实现相同的功能.请分享一些链接,我可以从中了解实施的结构和基本概念.

任何好的例子,如果包括在内,都会是一个加分.

在C中实施

c trie data-structures

4
推荐指数
1
解决办法
1万
查看次数

使用node.js上传文件

我有这个代码,以便使用node.js上传文件:

    app.use(express.bodyParser());
    // or, as `req.files` is only provided by the multipart middleware, you could 
    // add just that if you're not concerned with parsing non-multipart uploads, 
    // like:
    app.use(express.multipart());

    app.get('/',function(req,res){
    fs.readFile('uploadHTML.html',function (err, data){
        res.writeHead(200, {'Content-Type': 'text/html','Content-Length':data.length});
        res.write(data);
        res.end();
    });

    });
    app.post('/upload',function(req,res)
    {
    console.log(req.files);
    fs.readFile(req.files.displayImage.path, function (err, data) {
      // ...
      var newPath = __dirname;
      fs.writeFile(newPath, data, function (err) {
        res.redirect("back");
      });
    });
 });
Run Code Online (Sandbox Code Playgroud)

这是HTML文件:

<html>
<head>
<title>Upload Example</title>
</head>
<body>

<form id="uploadForm"
      enctype="multipart/form-data"
      action="/upload"
      method="post">
  <input type="file" id="userPhotoInput" name="displayImage" …
Run Code Online (Sandbox Code Playgroud)

javascript node.js express

4
推荐指数
1
解决办法
1万
查看次数

JAXB jar文件与java 1.6.0不兼容?

我是JAXB的新手,我想整理和解组XML/Objects to Objects/XML.

我从Sun的网站(价值22.69 MB)下载了JWSDP 2.0.

我已将环境变量设置为

JAVA_HOME :-   D:\Program Files\Java\jdk1.5.0  
JWSDP_HOME :-   D:\Sun\jwsdp-2.0  
JAXB_HOME :- D:\Sun\jwsdp-2.0\jaxb  
PATH :- D:\Program Files\Java\jdk1.5.0\bin;D:\Sun\jwsdp-2.0\jwsdp-shared\bin;  
Run Code Online (Sandbox Code Playgroud)

我正在尝试使用XJC(存在于其中)编译一个简单的XSD文件(名为tp.xsd D:\Sun\jwsdp-2.0\jaxb\bin).

当我尝试编译它时,我得到以下输出:

D:\ Sun\jwsdp-2.0\jaxb\bin> xjc tp.xsd

parsing a schema...  
compiling a schema...  
generated\Bookdata.java  
Exception in thread "main" java.lang.NoSuchMethodError: java.lang.Class.getSimpl
eName()Ljava/lang/String;  
        at com.sun.codemodel.JCodeModel$JReferencedClass.name(JCodeModel.java:54
5)  
        at com.sun.codemodel.JFormatter.t(JFormatter.java:283)  
        at com.sun.codemodel.JClass.generate(JClass.java:358)  
        at com.sun.codemodel.JFormatter.g(JFormatter.java:346)  
        at com.sun.codemodel.JAnnotationUse.generate(JAnnotationUse.java:388)  
        at com.sun.codemodel.JFormatter.g(JFormatter.java:346)  
        at com.sun.codemodel.JDefinedClass.declare(JDefinedClass.java:767)  
        at com.sun.codemodel.JFormatter.d(JFormatter.java:372)   
        at com.sun.codemodel.JFormatter.write(JFormatter.java:402)  
        at com.sun.codemodel.JPackage.build(JPackage.java:434)  
        at com.sun.codemodel.JCodeModel.build(JCodeModel.java:297)  
        at com.sun.codemodel.JCodeModel.build(JCodeModel.java:287)  
        at com.sun.tools.xjc.Driver.run(Driver.java:378)  
        at com.sun.tools.xjc.Driver.run(Driver.java:196)  
        at com.sun.tools.xjc.Driver._main(Driver.java:121)  
        at com.sun.tools.xjc.Driver.access$000(Driver.java:79)  
        at com.sun.tools.xjc.Driver$1.run(Driver.java:101) …
Run Code Online (Sandbox Code Playgroud)

jaxb

3
推荐指数
1
解决办法
7164
查看次数

“会话工厂”必须匹配“(property*,mapping*,(class-cache|collection-cache)*,event*,listener*)”

我找不到 hibernate.cfg.xml 文件有什么问题。

<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE hibernate-configuration PUBLIC
      "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
      "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd" >

<hibernate-configuration>
<session-factory>
- <!--  Database connection settings 
  --> 
  <property name="connection.driver_class">org.h2.Driver</property> 
  <property name="connection.url">jdbc:h2://localhost:1527/hibernatedb</property> 
  <property name="connection.username">h2</property> 
  <property name="connection.password" /> 
- <!--  JDBC connection pool (use the built-in) 
  --> 
  <property name="connection.pool_size">1</property> 

- <!--  Disable the second-level cache  
  --> 
  <property name="cache.provider_class">org.hibernate.cache.internal.CollectionCacheInvalidator
  </property> 
- <!--  Echo all executed SQL to stdout 
  --> 
  <property name="show_sql">true</property> 
- <!--  Drop and re-create the database schema on startup 
  --> 
  <property name="hbm2ddl.auto">create</property> 

  - <!-- …
Run Code Online (Sandbox Code Playgroud)

java hibernate sessionfactory hibernate.cfg.xml

3
推荐指数
1
解决办法
4498
查看次数

检测显示分辨率

我需要人们使用PHP检测设备显示分辨率的帮助.

切换界面时我的代码出现问题我有以下代码:

 $_page="home";
 if(get('page'))
    $_page=strtolower(get('page'));
 // Check if larger than 800px screen will show this code.
 $_pagePath='Includes/desktop/'.$_page.'_left.php';
 // Check if the screen is smaller than 800px will display this code.
 $_pagePath='Includes/mobile/'.$_page.'_left.php';  
 if(file_exists($_pagePath))
            include $_pagePath;
 else
    echo 'File '.$_pagePath.' not found';
Run Code Online (Sandbox Code Playgroud)

请帮我完成这段代码.

php mobile device-detection

2
推荐指数
1
解决办法
1万
查看次数

Trigger.io:forge.prefs函数中的变量范围

我们很难将forge.prefs值赋给变量,以便我们可以将其作为参数传递.

这是一个示例电话:

forge.prefs.get('offset_val' function(offset1){
     offset = offset1; 
})
forge.prefs.get('id', function(val){
     uid = val;
})

load_my_car(uid,offset);
Run Code Online (Sandbox Code Playgroud)

它正在返回,undefined并且在嵌套的prefs命令中调用它非常不方便.

有人可以帮我们解决这个问题吗?

javascript function trigger.io forge

1
推荐指数
1
解决办法
208
查看次数